-
Notifications
You must be signed in to change notification settings - Fork 16
/
json_patch.format.txt
42 lines (33 loc) · 3.1 KB
/
json_patch.format.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
JSON_PATCH
STANDARD ==> #RFC 6902
GOAL ==> #Perform patch on JSON, e.g. with HTTP PATCH
#As opposed to JSON merge patch:
# - more complex syntax
# - allow setting values to null
# - more flexible transformations (e.g. appending, splicing, copying|moving, simple branch)
#Still not suitable for complex (e.g. NUM++)
#Alternative: JSON merge patch (see its doc)
MIME ==> #application/json-patch+json
FORMAT ==> #Is OBJ_ARR:
# - op STR:
# - 'add': insertion or deep replace
# - 'remove'
# - 'replace': deep replace
# - 'move', 'copy'
# - 'test': stops patch if VAL != current value (deep comparison)
# - path PATH: JSON pointer
# - from PATH2 (op 'move|copy'): JSON pointer
# - value VAL (op 'add|replace|test')
#Note for ARR[NUM] (not ARR):
# - op 'add' inserts only
# - op 'remove' splices, i.e. shift remaining elements
MANIPULATION ==> #Operations applied in sequence
#If error, stops and rollbacks sequence of operations
# - with HTTP PATCH, should send 422 or 409
ERRORS ==> #Error happens if:
# - op 'test' failed
# - PATH does not exist for op 'remove|replace'
# - PATH2 does not exist for op 'move|copy'
# - PATH's parent does not exist for op 'add'