Parse Json string to Classic ASP page

18,383

Got it working:

Using https://github.com/rcdmk/aspJSON

Dim jsonString
jsonString = {"date":"4/28/2017","custType":"100","vehicle":"1"}

Dim jsonObj, outputObj
set jsonObj = new JSONobject
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>")

If you need to iterate through the single object use outputObj.pairs

Dim props, prop
props = outputObj.pairs
for each prop in props
    response.write prop.name & " : " & prop.value & "<br>"
next

as referenced https://github.com/rcdmk/aspJSON/issues/20

Share:
18,383
Ravi Ram
Author by

Ravi Ram

Dhali Website Design Website Design + Maintenance + Hosting. Quality Websites since 1996. http://dhali.com (949) 635-6954

Updated on June 04, 2022

Comments

  • Ravi Ram
    Ravi Ram almost 2 years

    What is the best way to parse json string into classic asp using a library?

    Dim jsonString
    jsonString = {"date":"4/28/2017","custType":"100","vehicle":"1"}
    

    Would like to have

    response.write("<li> date :" & json("date") & "</li>")
    
  • user692942
    user692942 about 7 years
    It's a really good library is that one, glad you found a solution.