rcdmk / aspJSON

A fast classic ASP JSON parser and encoder for easy JSON manipulation to work with the new JavaScript MV* libraries and frameworks.
MIT License
204 stars 89 forks source link

Error when parsing empty object #3

Closed nviet closed 9 years ago

nviet commented 9 years ago

I got syntax error message at line 324 when trying to parse an empty object exampleObject: []

value = eval(value)

How can I fix this?

rcdmk commented 9 years ago

Hi.

If I've understood it correctly, you are trying to parse a string with an empty array (e.g. JSON.parse("[]").

I'll take a look at this soon.

rcdmk commented 9 years ago

This should be fixed in the develop branch. I've made some changes there and will merge to máster today.

Also, to parse arrays, you should set the result to an object, since the parse method returns a reference to a JSONarray objct that representes the data:

JSONstring = "[]"
set jsonArr = JSON.parse(JSONstring)
JSON.write() ' outputs '{"data":[]}'
jsonArr.write() ' outputs '[]'