Public Function JSONParse(ByVal JSONPath As String, ByVal JSONString As String) As Variant
    Dim JSON As Object
    Set JSON = CreateObject("MSScriptControl.ScriptControl")
    JSON.Language = "JScript"
    JSONParse = JSON.eval("JSON=" & JSONString & ";JSON." & JSONPath & ";")
    Set JSON = Nothing
End Function

调用方式,
JSONPath为数据访问路径
JSONString为JSON格式数据
数据内容Data为
{
     "programmers": [{
         "firstName": "Brett",
         "lastName": "McLaughlin",
         "email": "aaaa"
     }, {
         "firstName": "Jason",
         "lastName": "Hunter",
         "email": "bbbb"
     }, {
         "firstName": "Elliotte",
         "lastName": "Harold",
         "email": "cccc"
     }],
     "authors": [{
         "firstName": "Isaac",
         "lastName": "Asimov",
         "genre": "sciencefiction"
     }, {
         "firstName": "Tad",
         "lastName": "Williams",
         "genre": "fantasy"
     }, {
         "firstName": "Frank",
         "lastName": "Peretti",
         "genre": "christianfiction"
     }],
     "musicians": [{
         "firstName": "Eric",
         "lastName": "Clapton",
         "instrument": "guitar"
     }, {
         "firstName": "Sergei",
         "lastName": "Rachmaninoff",
         "instrument": "piano"
     }]
}
-----------------
JSONParse("programmers.length", Data)
3

JSONParse("musicians[1].instrument", Data)
piano

GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 4 个月前
8c391e04 6 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐