-1

I have two large nested json objects which I need to compare for equality.

I followed the following steps but failed.

  1. I converted the json objects into treemaps and json arrays into hashsets and finally returned a treemap for each.

  2. I used equals method of map to compare for equality.

  3. Though both the maps are sorted(treemaps) and exactly equal in key,value pairs,the comparision is resulting in not equal Can anyone suggest a good solution for this and the reason why the case is failing?

eatSleepCode
  • 4,427
  • 7
  • 44
  • 93
Priya Mounica
  • 19
  • 1
  • 3

2 Answers2

1

See this answer here: Compare two JSON objects in Java

Covers the same thing. There's a number of ways, but I suggestion Jackson: https://github.com/FasterXML/jackson

Community
  • 1
  • 1
David Findlay
  • 1,296
  • 1
  • 14
  • 30
  • Thanks to all for your response. I solved it by converting the final thing to String and comparing both the strings. As both are in sorted order it worked. – Priya Mounica Sep 14 '16 at 13:41
1

To Check instantly,

try http://jsondiff.com/

For programmatic approach

provide a sample of your JSON Data and code.

UDID
  • 2,350
  • 3
  • 16
  • 31
mohit sharma
  • 1,050
  • 10
  • 20