When the fastJson tool class converts the installed list into JSONArray, the key whose value is null in the hashmap will also be lost.

Problems encountered: The fastJson utility class will have List&LT installed; HashMap> When converted to a JSONArray, the key with null value in the HashMap is also lost. Code:

JSONArray dataArray=JSONArray.parseArray(JSON.toJSONString(datalist))

 
Solutions:

JSONArray dataArray=JSONArray.parseArray(JSON.toJSONString(datalist,SerializerFeature.WriteMapNullValue))

 

Read More: