I have tried to compare those two JSON objects:
<input type="hidden" id="remoteJSON" name="remoteJSON" value='{"allowExternalMembers": "false", "whoCanJoin": "CAN_REQUEST_TO_JOIN"}' /><br />
<input type="hidden" id="localJSON" name="localJSON" value='{"whoCanJoin": "CAN_REQUEST_TO_JOIN", "allowExternalMembers": "false"}' /><br />
I got values with javascript and I tried to compare with : JSON.stringify(remoteJSON) == JSON.stringify(localJSON)
but this return false: it seems that the order of the properties is important.
And I even tried deep compare with this solution and always got a false return.
Is there a fast way to do the issue with jQuery (i.e. libraries for comparing JSON) ?
question from:
https://stackoverflow.com/questions/26049303/how-to-compare-two-json-have-the-same-properties-without-order 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…