1
假設我有這個JArray:合併重複達
{
"ArrayofItem":{
"Item":[
{
"Amount": "1.52"
"Date": "05/01/2015"
},
{
"Amount": "2.52"
"Date": "05/01/2015"
},
{
"Amount": "5.62"
"Date": "05/02/2015"
},
{
"Amount": "1.06"
"Date": "05/02/2015"
},
{
"Amount": "6.30"
"Date": "05/03/2015"
},
{
"Amount": "1.00"
"Date": "05/04/2015"
},
{
"Amount": "1.55"
"Date": "05/04/2015"
},
{
"Amount": "1.63"
"Date": "05/05/2015"
},
{
"Amount": "1.78"
"Date": "05/06/2015"
}
}
}
我怎樣才能鞏固項目,以便在同一日期的所有項目都結合在一起,形成一個新的JArray這樣的:
{
"ArrayofItem":{
"Item":[
{
"Amount": "4.04"
"Date": "05/01/2015"
},
{
"Amount": "6.68"
"Date": "05/02/2015"
},
{
"Amount": "6.30"
"Date": "05/03/2015"
},
{
"Amount": "2.55"
"Date": "05/04/2015"
},
{
"Amount": "1.63"
"Date": "05/05/2015"
},
{
"Amount": "1.78"
"Date": "05/06/2015"
}
}
}
本質上,我需要按原始項目的日期列表進行彙總。您可以假定這些項目已按日期排序。
似乎需要反序列化放入原始對象結構中,將其修改爲新結構並對其進行重新序列化。你試過什麼了? –
我編輯了你的標題。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –