从json string

时间:2017-11-02 00:42:15

标签: json vb.net json.net

我遇到了问题,我看到很多人试图将信息放入数组中,但我只是试图从json输出中获取两个值:

{
   "activated": true,
   "instance": 1509578457,
   "message": "2 out of 3 activations remaining",
   "timestamp": 1509578457,
   "sig": "79917b86cc1f0ce4205906add0be01d9"
}

我有newton.dll作为参考。我想做的是从'激活'和'消息'中提取信息并将它们放入变量中,这样我就可以随心所欲。有帮助吗?

1 个答案:

答案 0 :(得分:0)

试试这个

Dim jsonData As String = "{ 'activated': true,
                               'instance': 1509578457,
                               'message': '2 out Of 3 activations remaining',
                               'timestamp': 1509578457,
                               'sig': '79917b86cc1f0ce4205906add0be01d9'}" 
Dim o As Newtonsoft.Json.Linq.JObject = Json.JsonConvert.DeserializeObject(jsonData)

MsgBox(o.GetValue("activated"))