fastjson
fastjson copied to clipboard
Breaks with an empty JSON object
There seems to be a problem when jsonToArray() tries to parse an empty JSON object.
Example
For the following JSON
{"data":[{"pk_customer":"123","portalData":{}}]}
After running
put jsonToArray(theJson) into tResult
return arrayToJson(tResult)
We get
{"data":null}
However, if we run the same code for the slightly amended JSON
{"data":[{"pk_customer":"123","portalData":{""}}]}
We get
{"data":[{"portalData":null,"pk_customer":123}]}
According to JSONLint {} is valid JSON.
Obviously this issue is easy enough to work around using
replace "{}" with "{" & quote & quote & "}" in theJson
Thought I'd at least mention it here even if it doesn't get fixed someone might need the easy workaround in the future.