Skip to content

jsonpatch.generate modifies observed object #18

suhaig opened this Issue Aug 24, 2013 · 5 comments

3 participants

suhaig commented Aug 24, 2013


if I call jsonpatch.generate() the first time it generates the patches normally, but modifies the observed object, so the subsequent calls to jsonpatch.generate() don't generate any patches. Is it intentional, or is it a bug?



Hi Gábor,

Do you have any sample code to illustrate the issue? The intended behaviour is to generate patches for changes that follows the previous call to jsonpatch.generate(). I.e. the following chain of events should be true:

  1. Create some objects
  2. Change said objects
  3. Observe said objects (for the first time)
  4. Change said objects again
  5. Call generate - only changes in step 4 should be generated in the patch
  6. Change said objects yet another time
  7. Call generate a second time - only changes in step 6 should be generated in the patch
  8. Call generate a third time - no changes should be generated in the patch (as there are no changes since last patch)

If this is not what you are experiencing, please let me know.

suhaig commented Sep 2, 2013


if this is the intended behavior than no problem. I was not aware the fact that calling generate() resets the internal state.
In my use case the user fills out an HTML form and when she clicks the submit button I call jsonpatch.generate() to generate the patches and I send those patches to the backend. But the data can be invalid, so the user has to modify it, she clicks the submit button again and in this case I expect jsonpatch.generate() to return all the modifications.

suhaig commented Sep 2, 2013
warpech commented Nov 26, 2014

Fixed in 893e5f4 on master branch, soon to be released as version 0.5.0

@warpech warpech closed this Nov 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.