두 개의 배열이 있습니다.
[
{
account_id: '1000024965925119facebook',
account_name: 'JijoJohn',
account_image: '5133_a.jpg',
account_type: 'facebook'
},
{
account_id: '100002496592511facebook',
account_name: 'JijoJohn',
account_image: '55133_a.jpg',
account_type: 'facebook'
},
{
account_id: '138115932930527facebook',
account_name: 'JijoJohn',
account_image: '5555133_a.jpg',
account_type: 'facebook'
},
{
account_id: '101706396580621facebook',
account_name: 'JijoJohn',
account_image: '55133_a.jpg',
account_type: 'facebook'
},
{
account_id: 'feed1',
account_name: 'JijoJohn',
account_image: '5555133_a.jpg'
},
{
account_id: '57880525twitter',
account_name: 'MinuJose',
account_image: 'b4_normal.png',
account_type: 'twitter'
}
]
카운트 배열
[
{
type: 'facebook',
count: 4
},
{
type: 'twitter',
count: 1
}
]
두 번째 배열을 첫 번째 배열로 밀어 넣습니다.
connections.push(count);
내 요구 사항은 다음과 같이 결합 된 배열에 키 값을 추가하는 방법입니다. 각 어레이 앞에 계정을 추가하고 키를 계산해야합니다. 하나의 해결책을 찾도록 도와주세요. 감사
{
"accounts" :
[
{
account_id: '57880525twitter',
account_name: 'MinuJose',
account_image: 'b4_normal.png',
account_type: 'twitter'
},
{
account_id: '57880525twitter',
account_name: 'MinuJose',
account_image: 'b4_normal.png',
account_type: 'twitter'
}
],
"count" :
[
{
"type":"facebook",
"count": 4
} ,
{
"type":"twitter",
"count": 1
}
]
}
당신은 그것을 할 수 있습니다
var result = {
accounts: accountsArray,
counts: countsArray
}
(or)
var result = {
}
result.accounts = accountsArray;
result.counts = countsArray.
당신은 필요하지 않습니다 array.push
.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다