我想圖合併JSON。我有兩個JSON數組,並想從一個數組對象添加到另一個具有相同的價值觀JavaScript:將JSON對象從一個數組添加到另一個數組有條件地
產品
"Products": [
{
"Date": "2015-04-28T12:30:19.107",
"Code": "003UYTX1A",
"Title": "Divatex Dots Microfiber Queen Bed In the Bag",
"Description": "Go crazy with lots of dots with Divatex,
"Weight": 7.60,
"WeightUnit": "pounds",
"AverageRating": 4.1,
"EstimatedSalesPerDay": 761,
"ProfitScore": 50,
"UpdateStatus": 0,
"VersionCode": 23
},
{
"Date": "2015-04-28T12:29:46.66",
"Code": "05461AQDV",
"Title": "Wilton 1912-1294 100 Count Party Bags",
"Description": "Some Description,
"Weight": 8.10,
"WeightUnit": "pounds",
"AverageRating": 4.0,
"EstimatedSalesPerDay": 711,
"ProfitScore": 45,
"UpdateStatus": 0,
"VersionCode": 23
}]
詳細
"Detail": [
{
"Date": "2015-04-28T12:29:45.95",
"Code": "003UYTX1A",
"CategoryId": "1055398",
"CategoryTitle": "Some Title",
"TotalReviews": 31
},
{
"Date": "2015-04-28T12:29:45.95",
"Code": "05461AQDV",
"CategoryId": "1055398",
"CategoryTitle": "Title",
"TotalReviews": 211
},
{
"Date": "2015-04-28T12:29:45.95",
"Code": "003UYTX1A",
"CategoryId": "1055398",
"CategoryTitle": "Category Title",
"TotalReviews": 101
}]
我需要這些陣列組合的同一基礎上的對象Code
兩者的價值如下
"Combined": [
{
"Date": "2015-04-28T12:30:19.107",
"Code": "003UYTX1A",
"Title": "Divatex Dots Microfiber Queen Bed In the Bag",
"Description": "Go crazy with lots of dots with Divatex,
"Weight": 7.60,
"WeightUnit": "pounds",
"AverageRating": 4.1,
"EstimatedSalesPerDay": 761,
"ProfitScore": 50,
"UpdateStatus": 0,
"VersionCode": 23,
"Detail":[
{
"Date": "2015-04-28T12:29:45.95",
"Code": "003UYTX1A",
"CategoryId": "1055398",
"CategoryTitle": "Some Title",
"TotalReviews": 31
},
{
"Date": "2015-04-28T12:29:45.95",
"Code": "003UYTX1A",
"CategoryId": "1055398",
"CategoryTitle": "Category Title",
"TotalReviews": 101
}]
},
{
"Date": "2015-04-28T12:29:46.66",
"Code": "05461AQDV",
"Title": "Wilton 1912-1294 100 Count Party Bags",
"Description": "Some Description,
"Weight": 8.10,
"WeightUnit": "pounds",
"AverageRating": 4.0,
"EstimatedSalesPerDay": 711,
"ProfitScore": 45,
"UpdateStatus": 0,
"VersionCode": 23,
"Detail":[
{
"Date": "2015-04-28T12:29:45.95",
"Code": "05461AQDV",
"CategoryId": "1055398",
"CategoryTitle": "Title",
"TotalReviews": 211
}]
}]
任何bes t想法得到需要的結果?我必須在JavaScript中編碼。
嗯,我才意識到'where'也接受JSON參數。輝煌。 –