Foxtable(狐表)用户栏目专家坐堂 → [求助]如何使用json返回的数组?


  共有4694人关注过本帖平板打印复制链接

主题:[求助]如何使用json返回的数组?

帅哥哟,离线,有人找我吗?
智友软件工作室
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:912 积分:7445 威望:0 精华:0 注册:2013/2/25 13:10:00
[求助]如何使用json返回的数组?  发帖心情 Post By:2013/9/5 20:06:00 [只看该作者]

{
    "face": [
        {
            "attribute": {
                "age": {
                    "range": 5, 
                    "value": 12.5
                }, 
                "gender": {
                    "confidence": 60.6197, 
                    "value": "Female"
                }, 
                "race": {
                    "confidence": 99.9178, 
                    "value": "Asian"
                }, 
                "smiling": {
                    "value": 93.8853
                }
            }, 
            "face_id": "199d1efd19ce4ee67a7ec7655f859b1a", 
            "position": {
                "center": {
                    "x": 49.285714, 
                    "y": 18.5
                }, 
                "eye_left": {
                    "x": 44.718571, 
                    "y": 15.424933
                }, 
                "eye_right": {
                    "x": 53.37881, 
                    "y": 14.9466
                }, 
                "height": 11.666667, 
                "mouth_left": {
                    "x": 45.677381, 
                    "y": 22.597167
                }, 
                "mouth_right": {
                    "x": 51.64, 
                    "y": 22.462333
                }, 
                "nose": {
                    "x": 48.300714, 
                    "y": 19.778667
                }, 
                "width": 16.666667
            }, 
            "tag": ""
        }
    ], 
    "img_height": 1140, 
    "img_id": "892280e2a4b36175fea0b4377d635c51", 
    "img_width": 798, 
    "session_id": "02c0b5df1c6c4f59b80d10f80e3e7cfc", 
    "url": "http://faceplusplus.com/static/img/demo/1.jpg"
}

我用这个:
Dim key As String = e.Form.Controls("TextBox1").value
Dim secret As String = e.Form.Controls("TextBox2").value
Dim url As String = e.Form.Controls("TextBox3").value
Dim XMLH As Object
XMLH = CreateObject("Microsoft.XMLHTTP")
XMLH.open("GET", "https://apicn.faceplusplus.com/v2/detection/detect?url=" & url & "&api_secret=" & secret & "&api_key=" & key, True)   '获得实时信息
XMLH.send(Nothing)
Do While XMLH.readyState <> 4
    Application.DoEvents
Loop
'把数据json数据转化成对象
Dim json As String = XMLH.responseText
Dim ScriptControl As Object,data As Object,JscriptCode As String
JscriptCode = "function toObject(json) {eval(""var o=""+json);return o;}"
ScriptControl = CreateObject("MSScriptControl.ScriptControl")
With ScriptControl
    .Language = "Javascript"
    .Timeout = -1
    .AddCode(JscriptCode)
    data = .Run("toObject", json)
End With

MessageBox.Show(json)
e.Form.Controls("Label1").text = "img_height:" & data.img_height
e.Form.Controls("Label2").text = "img_width:" & data.img_width
e.Form.Controls("Label3").text = "img_id:" & data.img_id
e.Form.Controls("Label4").text = "session_id:" & data.session_id
e.Form.Controls("Label5").text = "url:" & data.url

已经读取了除face中的内容了。

请问如何读取这个face数组呢?

 回到顶部
总数 14 1 2 下一页