我有这个json
{
"query":{
"allcategories":{
"accontinue":"!!!_songs"
}
}
}
这是c#类:
public class Allcategories
{
public string accontinue { get; set; }
}
public class Query
{
public Allcategories allcategories { get; set; }
}
public class RootObject
{
public Query query { get; set; }
}
我能以某种方式映射下面的C#类吗?我想跳过一个级别,并像这样减少json的嵌套:
public class Query
{
[JsonAttribute("allcategories.accontinue")]
public string accontinue { get; set; }
}
public class RootObject
{
public Query query { get; set; }
}
答案 0 :(得分:0)
您建议的代码有效且会减少嵌套,但accontinue
将不再是Allcategories
对象,它将是Query
的字符串属性。