bruth / jsonpatch-js

A JavaScript implementation of the JSON Media Type for partial modifications: http://tools.ietf.org/html/rfc6902
http://bruth.github.io/jsonpatch-js
BSD 2-Clause "Simplified" License
181 stars 24 forks source link

Root level modifications aren't applied correctly? #25

Closed djMax closed 8 years ago

djMax commented 8 years ago

This line: https://github.com/bruth/jsonpatch-js/blob/master/jsonpatch.js#L519 feeds the ORIGINAL document into each successive step. Shouldn't it be feeding in result instead of document?

bruth commented 8 years ago

From the spec:

Each operation in the sequence is applied to the target document; the resulting document becomes the target of the next operation.

Nice catch. It is interesting no one has reported this before.

djMax commented 8 years ago

I think the reason is that it only affects the root key. Otherwise the changes are sort of fed back automatically.

bruth commented 8 years ago

Indeed.

On Oct 19, 2016, at 9:42 PM, Max Metral notifications@github.com wrote:

I think the reason is that it only affects the root key. Otherwise the changes are sort of fed back automatically.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bruth/jsonpatch-js/issues/25#issuecomment-254987622, or mute the thread https://github.com/notifications/unsubscribe-auth/AAfcRumEz4arkb1RaOhHTyN6_NX2X20bks5q1sb_gaJpZM4KaGDL.