将 Json 字符串解析为经典 ASP 页面 [英] Parse Json string to Classic ASP page

查看:47
本文介绍了将 Json 字符串解析为经典 ASP 页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用库将 json 字符串解析为经典 asp 的最佳方法是什么?

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"}

想要

response.write("<li> date :" & json("date") & "</li>")

推荐答案

搞定了:

使用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>")

如果您需要遍历单个对象,请使用 outputObj.pairs

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

参考https://github.com/rcdmk/aspJSON/issues/20

这篇关于将 Json 字符串解析为经典 ASP 页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆