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":""}}
此条目发表在学习笔记分类目录,贴了, , 标签。将固定链接加入收藏夹。

3 则回应给 vb解析json序列

  1. ijkou说:

    你好国栋,我是一个新手,偶然翻阅到此处,能否解释一下按钮事件里代码的意思?感激不尽!

    • ijkou说:

      我自己有一个json格式的文档,用你的代码调试时,到Set Psw = .Run(“toObject”, Text1.Text) 老是出现”无效字符“的提示,我的文档是UCS-2格式的,应该怎么改啊?

  2. 北京美容院装修说:

    面临节日快到了先祝贺楼主节日快乐,祝贺楼主幸福,圆满,安康一家团聚国庆节快乐http://school.gbci.cn北京幼儿园装修

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据