【发布时间】:2016-02-17 08:01:37
【问题描述】:
我是 JSON 和 API 的新手 我正在尝试从我拥有 Json 并想为其创建一个类的 API 中获取一些数据。当我使用 josn2csharp 转换它时,我得到以下代码。请让我知道我的课程的正确格式应该是什么,以便它转换为 json。
public class DataSet {
public string __invalid_name__-i:nil { get; set; } }
public class GenericObject {
public string __invalid_name__-xmlns:d2p1 { get; set; }
public string __invalid_name__-i:type { get; set; }
public string __invalid_name__#text { get; set; } }
public class Message {
public string __invalid_name__-i:nil { get; set; } }
public class FunctionResponse {
public string __invalid_name__-xmlns:i { get; set; }
public string __invalid_name__-xmlns { get; set; }
public DataSet DataSet { get; set; }
public GenericObject GenericObject { get; set; }
public Message Message { get; set; }
public string Success { get; set; } }
public class RootObject {
public FunctionResponse FunctionResponse { get; set; } }
使用this问题作为参考,我开始知道如何写作
公共字符串 invalid_name#text { get;放; }
但是其他人呢。 请帮忙
编辑 1:
{
"DataSet": {
"@nil": "true"
},
"GenericObject": {
"@type": "d2p1:boolean",
"#text": "true"
},
"Message": {
"@nil": "true"
},
"Success": "true"
}
【问题讨论】:
-
如您提到的问题的答案中所述,您可以将属性命名为任何名称,确保 JsonProperty 参数与您要解析的 json 的键匹配。
标签: c# json windows-phone-8.1 json.net