Forum Discussion

kolersa's avatar
kolersa
Contributor
9 years ago

GET DIFFERENCE BETWEEN 2 JSONS AND GET SURPLUS FOR JSON1 TO JSON2

How compare 2 json response, one like [{id:5, color:red}, {id:8, color:blue}{id:9, color:blue}{id:2, color:green}] and secound like {[id:2, status:1], [id:8, status:2],[id:100, status:1]}, I need comparing only for id value and other parameters should be ignored.

I wish to get difference between these jsons and get surplus for json1 to json2 and on the contrary, get surplus for json2 to json1.

Example:
json1:[{id:5, color:red}, {id:8, color:blue}{id:9, color:blue}{id:2, color:green}]
json2:{[id:2, status:1], [id:8, status:2],[id:100, status:1]}

surplus json1 - json2 by id= [{id:5, color:red}, {id:9, color:blue}]
surplus json2 - json1 by id= {[id:100, status:1]}