分类
学习笔记

vb解析json序列

工程示例下载:

http://url.cn/NsCT8e

按钮事件:


Private Sub Command1_Click()

   Dim ScriptControl As Object, Psw As Object, JscriptCode$
    JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
    Set ScriptControl = CreateObject("MSScriptControl.ScriptControl")
    With ScriptControl
        .Language = "Javascript"
        .Timeout = -1
        .AddCode JscriptCode
        Set Psw = .Run("toObject", Text1.Text)
    End With
    
    MsgBox "city:" & Psw.result.city & "retcode:" & Psw.retcode

End Sub
json示例:

{"retcode":0,"result":{"face":201,"birthday":{"month":10,"year":1899,"day":13},"occupation":"","phone":"","allow":1,"college":"","uin":57610310,"constel":9,"blood":1,"homepage":"","stat":10,"vip_info":0,"country":"中国","city":"宁波","personal":"\r\n","nick":"57610310","shengxiao":5,"email":"","client_type":41,"province":"浙江","gender":"male","mobile":""}}