fastjson icon indicating copy to clipboard operation
fastjson copied to clipboard

Breaks with an empty JSON object

Open MatthewHaughton opened this issue 6 years ago • 0 comments

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.

MatthewHaughton avatar Feb 28 '19 16:02 MatthewHaughton