Is there any way the JSON comparison ignores the whole section misplaced?
问题 I am trying to compare two JSON objects. When a 'key:value' pair order changes, I can use JSON.parse , and during comparison, the test passes like this: doc1 = '{ "KayA": "Value_A", "KeyB": "value_B" }' doc2 = '{ "KeyB": "value_B", "KayA": "Value_A" }' doc1 = JSON.parse(doc1) doc2 = JSON.parse(doc2) expect(doc1).to eq(doc2) # true But when the order of a section, an array, or a block of content changes, my assertion fails if I do the same comparison logic like below: doc1 = '{ "keys": [ {