in reply to Re^5: Create JSON patch (updated)
in thread Create JSON patch

This has the smell of NP completeness.

May be, I didn't (and won't) spend much time considering.

To solve the basic problem of creating any patch for a pair of random JSON documents, a quite relatively simple-minded diff-style algorithm should do the job. Very likely, the patch won't be the smallest possible patch in all cases, and it won't be elegant at all. But that approach has proven to work quite well for the last 43 years for all kind of text files, and especially for source code.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^7: Create JSON patch
by LanX (Saint) on Oct 07, 2017 at 14:56 UTC
    > work quite well for the last 43 years for all kind of text files, and ...

    text-diff / patch support "move" operations?

    I don't think so, that's why I asked the OP for clarification, what his "basic" problem is.

    We are comparing apples with gala dinners, the OP must be clearer about what kind of pony he wants.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      > work quite well for the last 43 years for all kind of text files, and ...

      text-diff / patch support "move" operations?

      No. Did I write that anywhere?

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
        Text diff is operating on a linear structure, an ordered list of lines (and this successfully for 43 years already ...)

        JSON describes a tree structure, and already the question how to order one level before comparing is problematic because the RFCs are not clear.

        Likening both is tempting but problematic.

        But I agree with you, I don't wanna spend more thought on this neither ...

        ...and a trivial solution is obvious:

        Patch: Remove all elements of A and insert all elements of B.

        Problem solved, thread closed! :)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!