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

Parse single item in json string with outer brackets #48

Closed RaviRamDhali closed 7 years ago

RaviRamDhali commented 7 years ago

Ricardo - I am getting an error when parsing JSON string using outer brackets. Is this a bug, or is this a 'feature'? I can trim the brackets, but I just wanted to let you know.

jsonString = [{"date":"4/28/2017","custType":"100","vehicle":"1"}] BROKEN vs jsonString = {"date":"4/28/2017","custType":"100","vehicle":"1"} WORKING

set outputObj = jsonObj.parse(jsonString)
response.write("<li> date :" & outputObj("date") & "</li>")
response.write("<li> custType :" & outputObj("custType") & "</li>")
response.write("<li> vehicle :" & outputObj("vehicle") & "</li>")
rcdmk commented 7 years ago

Hi. Square brackets denotes an array in JSON. When you parse an array, the parse method returns a jsonArray object and the jsonObject will contain a "data" property with the jsonArray object.

Take a look at the array examples in the README file.

RaviRamDhali commented 7 years ago

Make sense to me - thanks