varJS =NewSystem.Web.Script.Serialization.JavaScriptSerializer (); stringJSON ="{\ "offlinelock\": [{\ "id\": \ "4028d808581dab0f01581db51405001e\", \ "mac\": \ "d4:3d:7e:5f:b7:44\", \ "sdsl\": 5,\ " Sdrq\ ": 1477967156304,\" shlb\ ": \" 0\ "}],\" flag\ ": \" Success\ ", \" status\ ": \" 1400\ ", \" resultlist\ ": [{\" id\ ": \" 4028d808581dab0f01581db5145c001f\ ", \" zwjyzsbh\ ": \" 1000001600000052\ ", \" sfyfz\ ": \" 0\ "},{\" id\ ": \" 4028d808581dab0f01581db514780020\ ", \" zwjyzsbh\ ": \" 1000001600000054\ ", \" sfyfz\ ": \" 0\ "},{\" id\ ": \" 4028d808581dab0f01581db514950021\ ", \" zwjyzsbh\ ": \" 1000001600000056\ ", \" sfyfz\ ": \" 0\ "},{\" id\ ": \" 4028d808581dab0f01581db514b20022\ ", \" zwjyzsbh\ ": \" 1000001600000058\ ", \" sfyfz\ ": \" 0\ "},{\" id\ ": \" 4028d808581dab0f01581db514cc0023\ ", \" zwjyzsbh\ ": \" 1000001600000060\ ", \" sfyfz\ ": \" 0\ "}]}"; varJarr = js. deserialize<dictionary<string,Object>>(JSON); foreach(varJinchJarr) {Console.WriteLine (string. Format ("{0}:{1}", J.key, J.value)); } console.readline ();
The collection of key values through the subscript loop dictionary
for (int i = 0; i < Jarr. Count; i++)
{
var item = Jarr. ElementAt (i);//Gets the <key,value> value of the dictionary subscript as I
var Itemkey = Item. Key; Get the key value above
var itemvalue = Item. value;//get the value above
}
Parsing JSON into dictionary<key,value>