yudai / gojsondiff

Go JSON Diff
Other
535 stars 81 forks source link

how to deal with diffs of JSON where order of array elements isn't important #25

Closed madhukar93 closed 7 years ago

madhukar93 commented 7 years ago

A lot of JSON that I'm dealing with uses arrays as collections where order isn't important. Is there a workaround for this ? I thought of sorting the arrays and then comparing them, but if the JSON to be compared is available as a string then it has to be first deserialized into Go datastructure to sort. I was wondering if there's a simpler way to do this. Thanks for your work !

yudai commented 7 years ago

Hi @madhukar93 Unfortunately, there is no strait forward way to compare arrays as collection. As you mentioned, I think sorting them before comparing is the way to go.

madhukar93 commented 7 years ago

thanks, I'll try it out and report with findings if it's anything interesting.