Best way to compare 2 JSON files in Java

后端 未结 10 665
囚心锁ツ
囚心锁ツ 2020-12-13 13:56

How would you suggest this task is approached?

The challenge as i see it is in presenting diff information intelligently. Before i go reinventing the wheel, is there

10条回答
  •  青春惊慌失措
    2020-12-13 14:07

    I had a similar problem and ended up writing my own library:

    https://github.com/algesten/jsondiff

    It does both diffing/patching.

    Diffs are JSON-objects themselves and have a simple syntax for object merge/replace and array insert/replace.

    Example:

    original
    {
       a: { b: 42 }
    }
    
    patch
    {
      "~a": { c: 43 }
    }
    

    The ~ indicates an object merge.

    result
    {
       a: { b: 42, c: 43 }
    }
    

提交回复
热议问题