[Bug](Datax)Fix bug that the dataxwriter will drop column when convert map to json (#13042)

* fix bug that when value is null,toJSONString will drop this key value.
This commit is contained in:
Wilson-β
2022-09-29 11:37:10 +08:00
committed by GitHub
parent 6b6d548df9
commit 29fc167548
2 changed files with 4 additions and 1 deletions

View File

@ -180,6 +180,7 @@ PROPERTIES (
"password": "xxx",
"postSql": [],
"preSql": [],
"format":"csv|json",
"loadProps": {
},
"maxBatchRows" : 300000,
@ -191,5 +192,6 @@ PROPERTIES (
}
}
```
> 注意:```format``` 参数默认值:```csv```,如果想要使用```json```格式,需要在配置中指定```format``` 为```json```.
4.执行datax任务,具体参考 [datax官网](https://github.com/alibaba/DataX/blob/master/userGuid.md)

View File

@ -19,6 +19,7 @@ package com.alibaba.datax.plugin.writer.doriswriter;
import com.alibaba.datax.common.element.Record;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import java.util.HashMap;
import java.util.List;
@ -45,6 +46,6 @@ public class DorisJsonCodec extends DorisCodec {
rowMap.put(fieldName, this.convertColumn(row.getColumn(idx)));
++idx;
}
return JSON.toJSONString(rowMap);
return JSON.toJSONString(rowMap, SerializerFeature.WriteMapNullValue);
}
}