I want to insert values in to object based on id
inside that object.
First Object:
{
"topics": [{
"id": 131,
"topicId": "1485853106269",
"title": "Topic Title",
"details": "topic details",
"username": "ki****@gmail.com",
"userImage": "assets/img/spiritual-icon4.png",
"dayPosted": "1/31/2017, 5:16:53 PM"
}, {
"id": 132,
"topicId": "1485863413654",
"title": "Check",
"details": "topic details",
"username": "ki****@gmail.com",
"userImage": "assets/img/spiritual-icon4.png",
"dayPosted": "1/31/2017, 5:20:13 PM"
}, {
"id": 133,
"topicId": "1485945328280",
"title": "New Topic",
"details": "Sample Topic",
"username": "ki****@gmail.com",
"userImage": "assets/img/spiritual-icon4.png",
"dayPosted": "2/1/2017, 4:05:28 PM"
}, {
"id": 134,
"topicId": "1485945483238",
"title": "New Topic2",
"details": "New Topic2",
"username": "ki****@gmail.com",
"userImage": "assets/img/spiritual-icon4.png",
"dayPosted": "2/1/2017, 4:08:03 PM"
}],
"role": "ROLE_ADMIN"
}
Second Object:
{
"1485594764668": 1,
"1485853106269": 2,
"1485945483238": 1
}
I want to insert values from second object into first object based on the matching property "topicId": "1485853106269"
.
For example: The value of "topicId": "1485853106269"
in first object matches with a key inside second object so result would be like below with added value "count": 2
:
{
"id": 131,
"topicId": "1485853106269",
"title": "Topic Title",
"details": "topic details",
"username": "ki****@gmail.com",
"userImage": "assets/img/spiritual-icon4.png",
"dayPosted": "1/31/2017, 5:16:53 PM",
"count": 2 //ADDED here
}