【问题标题】:Json ,net is not workingJson,网络不工作
【发布时间】:2013-08-21 17:31:24
【问题描述】:

我正在尝试在 c# 中解析一个带有 json 网络的内容。我正在使用 json .net

但它显示以下异常

Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path '', line 1, position 1.

我正在用 jquery 创建 json 字符串。字符串的例子如下。

 {"0":{"tyreId":"","tyreNum":"dsf","tyreSecondHand":"false","tyreReplace":"true"},"1":{"tyreId":"","tyreNum":"gfd","tyreSecondHand":"true","tyreReplace":"true"}}

【问题讨论】:

标签: c# json


【解决方案1】:

JSON 文档表示具有键 "0""1" 的对象 (JObject)。它不是一个真正的数组,而是一个在某种程度上模仿数组的对象。

要么将文档作为对象读取,要么将文档固定为真正的数组:

[{"tyreId":"","tyreNum":"dsf","tyreSecondHand":"false","tyreReplace":"true"},{"tyreId":"","tyreNum":"gfd","tyreSecondHand":"true","tyreReplace":"true"}]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-16
    • 2013-10-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多