例如字符替换、json数组只取第一个元素的某些值以及内部的嵌套值~求指导
mwecs4sa1#
所有的嵌套,一招搞定转成标准json字符串后,etl处理,可以考虑jsonmap+laterval view当时结合处理//整段转义JsonWriterSettings build = JsonWriterSettings.builder().outputMode(JsonMode.EXTENDED).int64Converter((Long value, StrictJsonWriter writer) -> writer.writeString(Long.toString(value))).int32Converter((Integer value, StrictJsonWriter writer) -> writer.writeNumber(Integer.toString(value))).doubleConverter((Double value, StrictJsonWriter writer) -> writer.writeNumber(Double.toString(value))).decimal128Converter((Decimal128 value, StrictJsonWriter writer) -> writer.writeNumber(value.toString())).dateTimeConverter((Long value, StrictJsonWriter writer) -> writer.writeNumber(Long.toString(value))).timestampConverter((BsonTimestamp value, StrictJsonWriter writer) -> writer.writeNumber(Long.toString(value.getValue()))).build();
String docJson = item.toJson(build); JSONObject jsonObject = JSONObject.parseObject(docJson); String value = jsonObject.getString(columnName);
yzxexxkh2#
不好意思回复的有点晚了,请问您是在datax的reader插件处做了处理吗?
2条答案
按热度按时间mwecs4sa1#
所有的嵌套,一招搞定转成标准json字符串后,etl处理,可以考虑jsonmap+laterval view当时结合处理
//整段转义
JsonWriterSettings build = JsonWriterSettings.builder()
.outputMode(JsonMode.EXTENDED)
.int64Converter((Long value, StrictJsonWriter writer) -> writer.writeString(Long.toString(value)))
.int32Converter((Integer value, StrictJsonWriter writer) -> writer.writeNumber(Integer.toString(value)))
.doubleConverter((Double value, StrictJsonWriter writer) -> writer.writeNumber(Double.toString(value)))
.decimal128Converter((Decimal128 value, StrictJsonWriter writer) -> writer.writeNumber(value.toString()))
.dateTimeConverter((Long value, StrictJsonWriter writer) -> writer.writeNumber(Long.toString(value)))
.timestampConverter((BsonTimestamp value, StrictJsonWriter writer) -> writer.writeNumber(Long.toString(value.getValue())))
.build();
yzxexxkh2#
不好意思回复的有点晚了,请问您是在datax的reader插件处做了处理吗?