"fields": [
{
"field": {
"name": "SMS",
"value": "Yes"
}
},
{
"field": {
"name": "Email",
"value": ""
}
},
{
"field": {
"name": "Total",
"value": ""
}
},
]
我試圖形成如上所述的JSON格式,所以我形成了類如下所示。雖然序列化它不返回預期的形式,我怎麼能實現這一個。形成JSON對象 - 序列化C#
public class Test
{
public List<Field> fields;
}
public class Field
{
public string name { get; set; }
public string value { get; set; }
}
響應:
"fields": [{
"name": "SMS",
"value": "Yes"
}, {
"name": "Email",
"value": ""
},{
"name": "Total",
"value": ""
}]
你反對使用http://www.newtonsoft .COM/JSON? –
我不明白。你是說 - 你有一些輸入字符串 - >通過JSON.Net - >序列化到對象數組,這在反序列化不會返回原始字符串。是嗎? – RBT