fastjson
fastjson copied to clipboard
getString返回的数组中包含NULL时,该键都不返回
当json为如下时:{ `{ "payType": 2, "payer": "-", "payAmount": "2602", "chargeInfos": [{
"test": 1,
}, {
"test": null,
}, {
"test": null,
}, {
"test": null,
}, {
"test": null,
}
]
}` 此时getString("chargeInfos") 打印出来的是[{"test":1},{},{},{},{}],null都不返回
fastjson 2.0
JSON.toJSONString(obj, JSONWriter.Feature.WriteNulls);
fastjson 1.x
JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue);