如何从这个对象+ JSON.Net获得“v”的值

时间:2016-06-10 06:02:05

标签: c# json.net

如何使用JSON.Net从数据[“v”]获取价值

{
    "event": "ConnectTheDots",
    "data": "{ \"s\":\"wthr\",
           \"u\":\"F\",
           \"l\":\"Jaipur - The Pink City\",
           \"m\":\"Temperature\",
           \"o\":\"Nagarro\",
           \"v\": 3,
           \"d\":\"T" 
         }
    "published_at": "2016-06-08T11:48:32.772Z",
    "coreid": "2b0046000347343138333038",
    "guid": "2b0046000347343138333038",
    "timecreated": "2016-06-08T11:48:32.772Z",
    "location": "",
    "displayname": "",
    "organization": "",
    "value": "",
    "measurename": "",
    "unitofmeasure": "",
    "subject": ""
}

1 个答案:

答案 0 :(得分:1)

将其反序列化为动态对象。见Deserialize json object into dynamic object using Json.net

dynamic parsed = JObject.Parse(json);
var v = parsed.data.v;  // 3