mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-02 06:50:35 +08:00
增加column的type为json的支持,将object列转化为json字符串。
This commit is contained in:
parent
01e0723d65
commit
06e4b84bf0
@ -128,6 +128,8 @@ public class MongoDBReader extends Reader {
|
||||
while (columnItera.hasNext()) {
|
||||
JSONObject column = (JSONObject)columnItera.next();
|
||||
Object tempCol = item.get(column.getString(KeyConstant.COLUMN_NAME));
|
||||
String columnName = column.getString(KeyConstant.COLUMN_NAME);
|
||||
String columnType = column.getString(KeyConstant.COLUMN_TYPE);
|
||||
if (tempCol == null) {
|
||||
if (KeyConstant.isDocumentType(column.getString(KeyConstant.COLUMN_TYPE))) {
|
||||
String[] name = column.getString(KeyConstant.COLUMN_NAME).split("\\.");
|
||||
@ -151,6 +153,8 @@ public class MongoDBReader extends Reader {
|
||||
if (tempCol == null) {
|
||||
//continue; 这个不能直接continue会导致record到目的端错位
|
||||
record.addColumn(new StringColumn(null));
|
||||
} else if (columnType.equalsIgnoreCase("json")) {
|
||||
record.addColumn(new StringColumn(JSON.toJSONString(tempCol)));
|
||||
} else if (tempCol instanceof Double) {
|
||||
//TODO deal with Double.isNaN()
|
||||
record.addColumn(new DoubleColumn((Double) tempCol));
|
||||
|
Loading…
Reference in New Issue
Block a user