Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.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# 从Odata服务读取Json输出_C#_Json_Wcf_C# 4.0_Odata - Fatal编程技术网

C# 从Odata服务读取Json输出

C# 从Odata服务读取Json输出,c#,json,wcf,c#-4.0,odata,C#,Json,Wcf,C# 4.0,Odata,我试图以json格式读取odata服务的输出。但我得到的错误消息如下所示 响应有效负载不是有效的响应有效负载。请确保顶级元素是有效的Atom或JSON元素,或者属于命名空间 您输入的JSON字符串无效,因为它的属性名中带有“.”。 无法解析odata.metadata 如果您将其更改为odata_元数据,或者可能使用此处提供的解决方案:感谢您的回复。我已将odata格式设置为Nometadata,但仍会收到相同的错误。当前的输出是{value:[{ProductID:33,ProductName

我试图以json格式读取odata服务的输出。但我得到的错误消息如下所示

响应有效负载不是有效的响应有效负载。请确保顶级元素是有效的Atom或JSON元素,或者属于命名空间


您输入的JSON字符串无效,因为它的属性名中带有“.”。 无法解析odata.metadata


如果您将其更改为odata_元数据,或者可能使用此处提供的解决方案:

感谢您的回复。我已将odata格式设置为Nometadata,但仍会收到相同的错误。当前的输出是{value:[{ProductID:33,ProductName:Geitost,SupplierID:15,CategoryID:4,QuantityPerUnit:500g,单价:2.5000,UnitsInStock:112,UnitsOnOrder:0,ReorderLevel:20,Discontracted:false}]@travisco\u nabisco
NorthwindEntities dc = new NorthwindEntities(new Uri("http://services.odata.org/V3/Northwind/Northwind.svc/"),DataServiceProtocolVersion.V3);
        dc.Format.UseJson(new EdmModel());
        DataServiceQuery<Product> query = (DataServiceQuery<Product>)from o in dc.Products
            where o.UnitPrice > 0
            select o; query.execute();


{"odata.metadata":"http://services.odata.org/V3/Northwind/Northwind.svc/$metadata#Products","value":[{"ProductID":24,"ProductName":"Guaran\u00e1 Fant\u00e1stica","SupplierID":10,"CategoryID":1,"QuantityPerUnit":"12 - 355 ml cans","UnitPrice":"4.5000","UnitsInStock":20,"UnitsOnOrder":0,"ReorderLevel":0,"Discontinued":true},{"ProductID":33,"ProductName":"Geitost","SupplierID":15,"CategoryID":4,"QuantityPerUnit":"500 g","UnitPrice":"2.5000","UnitsInStock":112,"UnitsOnOrder":0,"ReorderLevel":20,"Discontinued":false}]}