fastjson icon indicating copy to clipboard operation
fastjson copied to clipboard

getString返回的数组中包含NULL时,该键都不返回

Open a877429929 opened this issue 3 years ago • 1 comments

当json为如下时:{ `{ "payType": 2, "payer": "-", "payAmount": "2602", "chargeInfos": [{

        "test": 1,

    }, {
        "test": null,

    }, {
        "test": null,

    }, {
        "test": null,

    }, {
        "test": null,
    }
]

}` 此时getString("chargeInfos") 打印出来的是[{"test":1},{},{},{},{}],null都不返回

a877429929 avatar Jul 01 '22 06:07 a877429929

fastjson 2.0

JSON.toJSONString(obj, JSONWriter.Feature.WriteNulls);

fastjson 1.x

JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue);

wenshao avatar Jul 02 '22 12:07 wenshao