Skip to content

Instantly share code, notes, and snippets.

@veelenga
Last active October 7, 2016 09:21
Show Gist options
  • Save veelenga/bfcb9575b798273ec5d5b9b270d0ec3f to your computer and use it in GitHub Desktop.
Save veelenga/bfcb9575b798273ec5d5b9b270d0ec3f to your computer and use it in GitHub Desktop.
# equal jsons
json1 = '{"polygons":[{"type":"rectangle","vertices":[{"x":1621.5,"y":1079.5},{"x":2674,"y":1079.5},{"x":2674,"y":2528},{"x":1621.5,"y":2528}],"category":"name"}]}'
json2 = '{"polygons":[{"type":"rectangle","category":"name","vertices":[{"x":1621.5,"y":1079.5},{"x":2674,"y":1079.5},{"x":2674,"y":2528},{"x":1621.5,"y":2528}]}]}'
rez1 = JSON.parse(json1)
rez2 = JSON.parse(json2)
rez1 == rez2 # true
# not equal jsons
json1 = '{"polygons":[{"type":"rectangle","vertices":[{"x":1621.5,"y":1079.5},{"x":2674,"y":1079.5},{"x":2674,"y":2528},{"x":1621.5,"y":2528}],"category":"name"}]}'
json2 = '{"polygons":[{"type":"rectangle","category":"name","vertices":[{"x":2621.5,"y":1079.5},{"x":2674,"y":1079.5},{"x":2674,"y":2528},{"x":1621.5,"y":2528}]}]}'
rez1 = JSON.parse(json1)
rez2 = JSON.parse(json2)
rez1 == rez2 # false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment