Parse Json string to Classic ASP page
Got it working:
Using https://github.com/rcdmk/aspJSON
Dim jsonStringjsonString = {"date":"4/28/2017","custType":"100","vehicle":"1"}Dim jsonObj, outputObjset jsonObj = new JSONobjectset 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>")
If you need to iterate through the single object use outputObj.pairs
Dim props, propprops = outputObj.pairsfor each prop in props response.write prop.name & " : " & prop.value & "<br>"next
as referenced https://github.com/rcdmk/aspJSON/issues/20
As a funny solution as the JSON keys are wrapped by double quote, this simple function can extract the key values (however it may need some more details to scape quotations within the values):
function getJsonKey(JsonString,key) myarray=split(JsonString,key,-1,1) if ubound(myarray)>0 then myarray2=split(myarray(1),chr(34),-1,1) getJsonKey=myarray2(2) else getJsonKey="" end ifend function