Releases: corka149/jsonpatch
Releases · corka149/jsonpatch
Edge cases and ignore invalid paths on opt-in
- Cover more edge cases (notably regarding the root document)
- Add option to ignore invalid paths
Favour maps for diffs
Better public API
Changes
- Bugfix - ADD behaviour is now compliant with RFC (insert or update)
- Bugfix - allow usage of nil values, previous implementation used
Map.get
with defaultnil
to detect if a key was not present - Change - COPY operation to be based on ADD operation (as per RFC)
- Change - MOVE operation to be based on COPY+REMOVE operation (as per RFC)
- Change - REPLACE operation to be based on REMOVE+ADD operation (as per RFC)
- Change -
Jsonpatch.apply_patch()
signature changes:- patches can be defined as
Jsonpatch.Operation.Add/Copy/Remove/...
structs or with plain map conforming to the jsonpatch schema - error reason is now defined with a
{:error, %Jsonpatch.Error{}}
tuple.
%Jsonpatch.Error{patch_index: _, path: _, reason: _} reports the patch index, the path and the reason that caused the error.
- patches can be defined as
- Removed -
Jsonpatch.Mapper
module, in favour of new Jsonpatch.apply_patch signature - Removed -
Jsonpatch.Operation
protocol - Feature - introduced new
Jsonpatch.apply_patch()
optionkeys: {:custom, convert_fn}
to convert path fragments with a user specific logic - Improvements - increased test coverage
Fix diff creation for Remove operations
BUGFIXES:
- Escape remaining keys before comparing them to the (already escaped) keys from earlier in the diffing process when determining Remove operations
Ready to battle
I know it exists but never had the time to fix it. I am talking about that patching of lists at top level never worked.
This was for me the milestone for v1.0.0. Finally it is fixed. 🥳.
Changes:
- Allow lists at top level of Jsonpatch.apply_patch
- Fix error message when updating a non existing key in list
Performance improvement
- Make Jsonpatch faster by (un)escaping conditional
Allow usage of atoms
Now it is possible to patch maps with atoms as keys via the following options:
:keys
- controls how parts of paths are decoded. Possible values::strings
(default) - decodes parts of paths as binary strings,:atoms
- parts of paths are converted to atoms usingString.to_atom/1
,:atoms!
- parts of paths are converted to atoms usingString.to_existing_atom/1
Better order for generated diffs
Generate diffs with correct order (thanks https://github.com/smartepsh)
Remove own ordering of patches before applying
Previously Jsonpatch sorted the patches before applying them when they were provided as list. This was wrong.
The RFC says that they should be applied in the order as they appear in the list.
Improved patch creation by diff
- Removed module Jsonpatch.FlatMap because it is not necessary anymore and not the focus of the lib
- Reworked creating diff to create less unnecessary data and for more accurate patches
- Fixed adding values to empty lists (thanks https://github.com/webdeb)