benjamine / jsondiffpatch

Diff & patch JavaScript objects
MIT License
4.86k stars 472 forks source link

Json Patch (RFC 6902) formatter should escape the property name #371

Open nathangobinet opened 3 months ago

nathangobinet commented 3 months ago

Migrating from fast-json-patch to jsondiffpatch I encouter an error using a property name that include a '/' character with the jsonpatch formatter.

The following object property name:

tree/item

should be formatted as

tree~1item

and is formatted as :

tree/item

causing wrong jsonpatch operation path.

See RFC 6902 for details : https://datatracker.ietf.org/doc/html/rfc6902#appendix-A.14