아래처럼 값은 동일하지만 순서가 다른 것을 비교할 경우, object를 정렬한 후 비교한다
const capaObj = { "temperature": "number", "humidity": "number" }
const payloadObj = { "humidity": "number", "temperature": "number" }
// capaObj와 payload 비교하기
console.log(JSON.stringify(capaObj) === JSON.stringify(payloadObj)); // false
let capa_sort = Object.keys(capaObj).sort().reduce((obj, key) => (obj[key] = capaObj[key], obj), {});
let payload_sort = Object.keys(payloadObj).sort().reduce((obj, key) => (obj[key] = payloadObj[key], obj), {});
console.log(capa_sort);
console.log(payload_sort);
console.log(JSON.stringify(capa_sort) === JSON.stringify(payload_sort)); // true
const isEqual = JSON.stringify(capa_sort) === JSON.stringify(payload_sort);