Getting a diff of two JSON strings using Java code

后端 未结 4 1001
无人及你
无人及你 2020-12-15 21:55

Can anybody suggest some Java Library or Code to get a diff of two JSON Strings?

4条回答
  •  独厮守ぢ
    2020-12-15 22:43

    I had the exact same 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 }
    }
    

提交回复
热议问题