0
我有從列表序列化爲下面追加項目到現有的Json與Newtonsoft JSON
var products= JsonConvert.SerializeObject(produstList, Formatting.Indented);
{
"Products": [
{
"Name": "Sample Product",
"Id": "LT2134",
"ProcudtCode": "001KP"
}
]
}
現有JSON想要apped另一個串行化JSON對象(產品列表),以上述一個這樣的下方,在那裏我可以做到這一點的一種方式。
{
"Products": [
{
"Name": "Sample Product",
"Id": "LT2134",
"ProcudtCode": "001KP"
}
],
"ProductList": [
{
"Category": "Electronics",
"SubCategory": "Router",
"ProcudtCode": "001KP",
"Description": "wifi router",
"Brand": "test"
}
]
}
請幫我
你究竟試過了什麼?你卡在哪裏?從你的問題來看,這不是很明顯。 –
我試圖將使用Jobject的新json對象添加到下面的現有列表中。但沒有獲得有效的json。 JObject jo = JObject.FromObject(produstList); var products = JsonConvert.SerializeObject(Products,Formatting.Indented); jo.Add(「ProductsList」,產品); – Das