{
"result": {
"position": [
0.0,
0.0
],
"msg": "OK"
}
}
返回的格式是这样的,我找的网上的反序列化都是只能对中间那个大括号也就是result之后那个大括号进行,对这条信息没法识别,求教怎么解决,谢了
要建立好类模型就可以序列化了,以下是居于Newtonsoft.Json.Net20.dll下载实现的,自己下载这个类库
protected void Page_Load(object sender,EventArgs e)
{
string s = "{\"result\": {\"position\": [0.0,0.0],\"msg\": \"OK\"}}";
MyJson r = Newtonsoft.Json.JsonConvert.DeserializeObject<MyJson>(s);
Response.Write(r.result.msg+"<BR>");
Response.Write(r.result.position[0]);
}
public class Result { public float[] position; public string msg;}
public class MyJson { public Result result;}