我是靠谱客的博主 如意流沙,这篇文章主要介绍VB 解析 JSON,现在分享给大家,希望可以做个参考。

{"ecode":0,"exp":4,"limit":0,"pkg":[{"id":1,"name":"元宝","num":1000,"type":39}],"ref_limit":0,"ret":0,"wish_num":1,"wish_t":1499612867}

函数过程

Public Function Json(ByVal JSONPath As String, ByVal JSONString As String) As Variant
    On Error Resume Next
    Dim JS As Object
    If JSONString = "" Then Exit Function
    Set JS = CreateObject("MSScriptControl.ScriptControl")
    JS.Language = "JScript"
    Json = JS.Eval("JSON=" & JSONString & ";JSON." & JSONPath & ";")
    Set JS = Nothing
End Function


调用:

1、直接取值

ecode=Json("ecode", JsonString)

2、数组长度获取

pkgCount=Json("pkg.length", JsonString)

3、数组内取值

cName=Json("pkg[0].name",JsonString)

最后

以上就是如意流沙最近收集整理的关于VB 解析 JSON的全部内容,更多相关VB内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(72)

评论列表共有 0 条评论

立即
投稿
返回
顶部