C# JObject出现问题。在Windows Phone 8中解析为动态类型
在控制台应用程序中,我运行以下代码:C# JObject出现问题。在Windows Phone 8中解析为动态类型,c#,json,dynamic,windows-phone-8,json.net,C#,Json,Dynamic,Windows Phone 8,Json.net,在控制台应用程序中,我运行以下代码: string json = "{\"id\": \"5\"}"; dynamic result = JObject.Parse(json); var id = result.id; 结果: id = 5; 在使用此代码的Windows Phone 8中,我有一个例外: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException 我有Newtonsoft.Json5.0.8版 有什么问题吗?我想你必须找到你
string json = "{\"id\": \"5\"}";
dynamic result = JObject.Parse(json);
var id = result.id;
结果:
id = 5;
在使用此代码的Windows Phone 8中,我有一个例外:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
我有Newtonsoft.Json
5.0.8版
有什么问题吗?我想你必须找到你的数据,因为结果是JObject 所以
var id=result[“id”]代码>
在哪一行出现错误?在这一行中,var id=result.id;我解决了这个问题。在Windows Phone works中,var id=result[“id”];