0

我有来自 http 帖子的以下 json 字符串:

Dim json As String = "{" + """contacts"":" + "[{" + """name"":""jocelyne" + """," + """mo"":""jocelyne" + """}" + ",{" + """name"":""eliane" + """," + """mo"":""12345678" + """}" + "]}"

我如何反序列化这个 json 数组?我尝试使用字典,但它不起作用请注意 json 数组的长度可能非常大

 Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer()
 Dim dict As Dictionary(Of String, String) = jss.Deserialize(Of Dictionary(Of String, String))(json)
 For Each item As KeyValuePair(Of String, String) In dict
        Response.Write(item.Key & " - " & item.Value & "<br>")
    Next
4

3 回答 3

0

尝试使用JSON.Net

  Dictionary<string,string> deserializedProduct =
    JsonConvert.DeserializeObject<Dictionary<string,string>>(json);
于 2013-10-17T11:33:27.093 回答
0

试试这个,这是C#代码

dynamic obj = JsonConvert.DeserializeObject(json);
var contacts = obj["contacts"];
于 2013-10-17T11:37:17.173 回答
0

尝试这个

   System.Web.Script.Serialization.JavaScriptSerializer ss1 = new System.Web.Script.Serialization.JavaScriptSerializer();
Dictionary<string, string> dicobj = new Dictionary<string, string>();
        dicobj = ss1.DeserializeObject(JsonString) as Dictionary<string, string>;
于 2013-10-17T11:38:49.793 回答