Json 命名问题
Json Naming issue
我是 JSON 和 API 的新手
我正在尝试从我有 Json 的 API 获取一些数据,并想为 it.when 创建一个 class 我使用 josn2csharp 转换它 我得到以下代码。请让我知道我的 class 的正确格式应该是什么,以便它转换为 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问题作为参考我开始知道如何写
public 字符串 invalid_name#text { get;放; }
但是其他人呢。
请帮忙
编辑 1:
{
"DataSet": {
"@nil": "true"
},
"GenericObject": {
"@type": "d2p1:boolean",
"#text": "true"
},
"Message": {
"@nil": "true"
},
"Success": "true"
}
示例:
{
"json":
{
"#thekeyinsidejsonproperty": "value"
}
}
你应该
public class RootObject
{
[JsonProperty("json")]
public Json jsonobj;
}
public class Json
{
[JsonProperty("#thekeyinsidejsonproperty")]
public string somepropertyname{ get; set; }
}
希望对您有所帮助! :)
我是 JSON 和 API 的新手 我正在尝试从我有 Json 的 API 获取一些数据,并想为 it.when 创建一个 class 我使用 josn2csharp 转换它 我得到以下代码。请让我知道我的 class 的正确格式应该是什么,以便它转换为 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问题作为参考我开始知道如何写
public 字符串 invalid_name#text { get;放; }
但是其他人呢。 请帮忙
编辑 1:
{
"DataSet": {
"@nil": "true"
},
"GenericObject": {
"@type": "d2p1:boolean",
"#text": "true"
},
"Message": {
"@nil": "true"
},
"Success": "true"
}
示例:
{
"json":
{
"#thekeyinsidejsonproperty": "value"
}
}
你应该
public class RootObject
{
[JsonProperty("json")]
public Json jsonobj;
}
public class Json
{
[JsonProperty("#thekeyinsidejsonproperty")]
public string somepropertyname{ get; set; }
}
希望对您有所帮助! :)