C# Json,网络不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18364023/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Json ,net is not working
提问by ap.singh
I am trying to parse an with json net in c#. And i am using json .net
我正在尝试在 c# 中使用 json net 解析一个。我正在使用 json .net
But it is showing the following exception
但它显示以下异常
Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path '', line 1, position 1.
i am creating json string with jquery. And the example of string is as follows.
我正在用 jquery 创建 json 字符串。字符串的例子如下。
{"0":{"tyreId":"","tyreNum":"dsf","tyreSecondHand":"false","tyreReplace":"true"},"1":{"tyreId":"","tyreNum":"gfd","tyreSecondHand":"true","tyreReplace":"true"}}
采纳答案by cdhowie
The JSON document represents an object (JObject
) with the keys "0"
and "1"
. It is not a true array, but rather an object that somewhat mimics an array.
JSON 文档表示一个对象 ( JObject
),其键为"0"
和"1"
。它不是一个真正的数组,而是一个有点模仿数组的对象。
Either read the document as an object, or fix the document to be a real array:
要么将文档作为对象读取,要么将文档固定为一个真正的数组:
[{"tyreId":"","tyreNum":"dsf","tyreSecondHand":"false","tyreReplace":"true"},{"tyreId":"","tyreNum":"gfd","tyreSecondHand":"true","tyreReplace":"true"}]