Untitled
plain_text
a month ago
505 B
1
Indexable
Never
const json1 = '{"hello":"world", "hi":"hello", "you":"me", "abc": "dfg"}'; const json2 = '{"hello":"world", "hi":"helloo", "you":"me", "abc": "123"}'; function getJSONDiff(json1, json2) { const different_keys = []; const objJSON1 = JSON.parse(json1); const objJSON2 = JSON.parse(json2); for (let key in objJSON1) { if (objJSON1[key] !== objJSON2[key]) { different_keys.push(key); } } different_keys.sort(); return different_keys; } console.log(getJSONDiff(json1, json2));