[
{
"r1": {
"needs": [
{
"need": "678",
"score": 102,
"category1": "保6",
"category2": "男士产品"
},
{
"need": "紧紧致",
"score": 23,
"category1": "紧 老",
"category2": "护 品"
}
],
"skus": [
{
"score": 126660.69,
"category1": "护 产 品",
"code": "G1305001",
"category3": "抗 致",
"category2": "乳液",
"category4": "对 初老"
}
]
}
},
{
"r2": {
"needs": [
{
"need": "脸 美妆",
"score": 102,
"category1": "脸 品",
"category2": "彩 品"
},
{
"need": "脸部 桃花妆",
"score": 23,
"category1": "脸 品",
"category2": "彩 品"
}
],
"skus": [
{
"score": 126.69,
"category1": "彩品",
"code": "G13201",
"category3": "脸",
"category2": "粉液",
"category4": "雅韵妆"
}
]
}
},
{
"r3": {
"needs": [
{
"need": "修受损",
"score": 102,
"category1": "修受损",
"category2": "护产品"
},
{
"need": "修复日常受损;",
"score": 23,
"category1": "修复日常受损;莹润滋养;丝质顺滑",
"category2": "护品"
}
],
"skus": [
{
"score": 120.69,
"category1": "护发产品",
"code": "G1268801",
"category3": "修复日常受损;丝质顺滑",
"category2": "精油",
"category4": "修复日常受损;丝质顺滑"
}
]
}
},
{
"r4": {
"needs": [
{
"need": "时尚系",
"score": 102,
"category1": "时色",
"category2": "染品"
},
{
"need": "时系",
"score": 23,
"category1": "时色",
"category2": "染品"
}
],
"skus": [
{
"score": 1.69,
"category1": "产品",
"code": "G134031",
"category3": "发色",
"category2": "",
"category4": "色系"
}
]
}
}
]
可以直接用Json.net来反序列化吗
可以解析成一个键值对数组
Key是一个字符串 Value类型照着格式定义就行.
public class Need { public string need { get; set; } public int score { get; set; } public string category1 { get; set; } public string category2 { get; set; } } public class Sku { public double score { get; set; } public string category1 { get; set; } public string code { get; set; } public string category3 { get; set; } public string category2 { get; set; } public string category4 { get; set; } } public class R1 { public List<Need> needs { get; set; } public List<Sku> skus { get; set; } } public class Need2 { public string need { get; set; } public int score { get; set; } public string category1 { get; set; } public string category2 { get; set; } } public class Sku2 { public double score { get; set; } public string category1 { get; set; } public string code { get; set; } public string category3 { get; set; } public string category2 { get; set; } public string category4 { get; set; } } public class R2 { public List<Need2> needs { get; set; } public List<Sku2> skus { get; set; } } public class Need3 { public string need { get; set; } public int score { get; set; } public string category1 { get; set; } public string category2 { get; set; } } public class Sku3 { public double score { get; set; } public string category1 { get; set; } public string code { get; set; } public string category3 { get; set; } public string category2 { get; set; } public string category4 { get; set; } } public class R3 { public List<Need3> needs { get; set; } public List<Sku3> skus { get; set; } } public class Need4 { public string need { get; set; } public int score { get; set; } public string category1 { get; set; } public string category2 { get; set; } } public class Sku4 { public double score { get; set; } public string category1 { get; set; } public string code { get; set; } public string category3 { get; set; } public string category2 { get; set; } public string category4 { get; set; } } public class R4 { public List<Need4> needs { get; set; } public List<Sku4> skus { get; set; } } public class RootObject { public R1 r1 { get; set; } public R2 r2 { get; set; } public R3 r3 { get; set; } public R4 r4 { get; set; } }
谢谢,不过RootObject deserializeObject = JsonConvert.DeserializeObject<RootObject>(jsonString);貌似还是报错了。。
路过...不是搞C#,呵呵!