Bootstrap

[vb6.0] 解析JSON

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 "province:" & Psw.result.province '& vbCrLf & "day1:" & Psw.result.birthday.day1 & vbCrLf & "city:" & Psw.result.city
    MsgBox "province:" & Psw.result.country
    MsgBox "province:" & Psw.result.nick
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":""}}
;