Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.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# 无法在C中反序列化JSON字符串_C#_Json_Json.net - Fatal编程技术网

C# 无法在C中反序列化JSON字符串

C# 无法在C中反序列化JSON字符串,c#,json,json.net,C#,Json,Json.net,我从第三方收到以下JSON字符串: { "Ch": [{ "i": 100, "m": "Time", "u": "(sec)", "d": 0, "z": 0.345313, "yi": "0.000000", "ya": "6.906250", "a": 0, "s": 1664, "data": "RN]]>"

我从第三方收到以下JSON字符串:

{
    "Ch": [{
        "i": 100,
        "m": "Time",
        "u": "(sec)",
        "d": 0,
        "z": 0.345313,
        "yi": "0.000000",
        "ya": "6.906250",
        "a": 0,
        "s": 1664,
        "data": "RN]]>"
    }, {
        "i": 101,
        "m": "Stress",
        "u": "(kPa)",
        "d": 0,
        "z": 60,
        "yi": "0.000000",
        "ya": "1200.000000",
        "a": 0
    }, {
        "i": 102,
        "m": "Strain",
        "u": "(micro e)",
        "d": 0,
        "z": 8,
        "yi": "200.000000",
        "ya": "360.000000",
        "a": 0
    }, {
        "i": 103,
        "m": "Stress",
        "u": 360,
        "d": 0,
        "z": 0,
        "yi": "0.000000",
        "ya": "0.000000",
        "a": 0,
        "s": 1664,
        "data": "QVORR`Pb_UQRR</code>OObTNRRUTaWRVRRSaPQPdRRaPNSORRR]]>"
    }, {
        "i": 104,
        "m": "Strain",
        "u": 360,
        "d": 0,
        "z": 0,
        "y": 0,
        "yi": "0.000000",
        "ya": "0.000000",
        "a": 1,
        "s": 1664,
        "data": "SVdRQSP_VWQRQa]]>"
    }]
}
我使用以下类别:

public class testCh
{
    public int i { get; set; }
    public string m { get; set; }
    public object u { get; set; }
    public int d { get; set; }
    public double z { get; set; }
    public string yi { get; set; }
    public string ya { get; set; }
    public int a { get; set; }
    [JsonIgnore]
    public int s { get; set; }
    [JsonIgnore]
    public string data { get; set; }

}

public class testRootObject
{
    public List<testCh> tCh { get; set; }
}
但它不起作用

我不知道为什么我不能反序列化它。这一定是件傻事,但试了几天后我就看不见了


非常感谢任何帮助或提示。

我已经检查并确认了这一点。这里唯一的错误是列表对象的名称。它应该是json字符串中的Ch

public class testRootObject
{
    public List<testCh> Ch { get; set; }
}

请格式化你的JSON。将testRootObject类的tCh属性重命名为Ch是完全不可行的。请为该对象尝试相同的名称。。。在c类和json中。因为它寻找一个匹配的名字。@JasonBoyd它成功了。谢谢
[JsonIgnore]
public int s { get; set; }

[JsonIgnore]
public string data { get; set; }
public class testRootObject
{
    public List<testCh> Ch { get; set; }
}
public class testRootObject
{
    [JsonProperty("Ch")]
    public List<testCh> tCh { get; set; }
}