bhall2001 / fastjson

A Livecode library for JSON encoding and decoding to and from Arrays.
MIT License
17 stars 11 forks source link

Breaks with an empty JSON object #34

Open MatthewHaughton opened 5 years ago

MatthewHaughton commented 5 years ago

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.