读Json数组

时间:2014-03-21 14:57:12

标签: arrays json vb.net

如何阅读' status'的值?在这个数组中使用vb.net?

{"message-count":1,
>> "messages":[{
>> "status":0,
>>"to":"XXXXXXXXX",
>>"client-ref":"",
>>"message-id":"030350003865BC53",
>>"message-price":"X.XXX",
>>"remaining-balance":X.XXX}
]}

1 个答案:

答案 0 :(得分:0)

如果您真的希望此代码能够正常工作,那么您需要知道DeserializeObject返回的对象是字符串,对象的通用字典。这是以这种方式执行的代码:

     var json_serializer = new JavaScriptSerializer();
        var routes_list = (IDictionary<string, object>)json_serializer.DeserializeObject(
    "{\"message-count\":1,
    \"messages\":[{
    \"status\":0,
    \"to\":\"XXXXXXXXX\",
    \"client-ref\":\"\",
    \"message-id\":"030350003865BC53\",
    \"message-price":\"X.XXX\",
    \"remaining-balance\":X.XXX}
    ]}
    "

);
    Console.WriteLine(routes_list["test"]);