Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# JObject出现问题。在Windows Phone 8中解析为动态类型_C#_Json_Dynamic_Windows Phone 8_Json.net - Fatal编程技术网

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”];