Skip to content

Commit 994ed8a

Browse files
committed
add example from 4.1: add with non-existing path
1 parent 6ff1515 commit 994ed8a

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

spec_tests.json

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
[
2+
{
3+
"comment": "4.1. add with missing object",
4+
"doc": { "q": { "bar": 2 } },
5+
"patch": [ {"op": "add", "path": "/a/b", "value": 1} ],
6+
"error":
7+
"path /a does not exist -- missing objects are not created recursively"
8+
},
9+
210
{
311
"comment": "A.1. Adding an Object Member",
412
"doc": {
@@ -14,7 +22,7 @@
1422
},
1523

1624
{
17-
"comment": "A.2. Adding an Array Element",
25+
"comment": "A.2. Adding an Array Element",
1826
"doc": {
1927
"foo": [ "bar", "baz" ]
2028
},
@@ -58,7 +66,7 @@
5866
"doc": {
5967
"baz": "qux",
6068
"foo": "bar"
61-
},
69+
},
6270
"patch": [
6371
{ "op": "replace", "path": "/baz", "value": "boo" }
6472
],
@@ -78,10 +86,10 @@
7886
"qux": {
7987
"corge": "grault"
8088
}
81-
},
89+
},
8290
"patch": [
8391
{ "op": "move", "from": "/foo/waldo", "path": "/qux/thud" }
84-
],
92+
],
8593
"expected": {
8694
"foo": {
8795
"bar": "baz"
@@ -97,10 +105,10 @@
97105
"comment": "A.7. Moving an Array Element",
98106
"doc": {
99107
"foo": [ "all", "grass", "cows", "eat" ]
100-
},
108+
},
101109
"patch": [
102110
{ "op": "move", "from": "/foo/1", "path": "/foo/3" }
103-
],
111+
],
104112
"expected": {
105113
"foo": [ "all", "cows", "eat", "grass" ]
106114
}
@@ -131,7 +139,7 @@
131139
"patch": [
132140
{ "op": "test", "path": "/baz", "value": "bar" }
133141
],
134-
"error": "string not equivalent"
142+
"error": "string not equivalent"
135143
},
136144

137145
{
@@ -150,21 +158,21 @@
150158
}
151159
}
152160
},
153-
161+
154162
{
155163
"comment": "A.11. Ignoring Unrecognized Elements",
156164
"doc": {
157165
"foo":"bar"
158-
},
166+
},
159167
"patch": [
160168
{ "op": "add", "path": "/baz", "value": "qux", "xyz": 123 }
161169
],
162170
"expected": {
163-
"foo":"bar",
171+
"foo":"bar",
164172
"baz":"qux"
165173
}
166174
},
167-
175+
168176
{
169177
"comment": "A.12. Adding to a Non-existant Target",
170178
"doc": {
@@ -175,7 +183,7 @@
175183
],
176184
"error": "add to a non-existant target"
177185
},
178-
186+
179187
{
180188
"comment": "A.13 Invalid JSON Patch Document",
181189
"doc": {
@@ -186,8 +194,8 @@
186194
],
187195
"error": "operation has two 'op' members"
188196
},
189-
190-
{
197+
198+
{
191199
"comment": "A.14. ~ Escape Ordering",
192200
"doc": {
193201
"/": 9,
@@ -196,11 +204,11 @@
196204
"patch": [{"op": "test", "path": "/~01", "value": 10}],
197205
"expected": {
198206
"/": 9,
199-
"~1": 10
207+
"~1": 10
200208
}
201209
},
202210

203-
{
211+
{
204212
"comment": "A.15. Comparing Strings and Numbers",
205213
"doc": {
206214
"/": 9,
@@ -210,15 +218,15 @@
210218
"error": "number is not equal to string"
211219
},
212220

213-
{
221+
{
214222
"comment": "A.16. Adding an Array Value",
215223
"doc": {
216224
"foo": ["bar"]
217225
},
218226
"patch": [{ "op": "add", "path": "/foo/-", "value": ["abc", "def"] }],
219227
"expected": {
220-
"foo": ["bar", ["abc", "def"]]
228+
"foo": ["bar", ["abc", "def"]]
221229
}
222230
}
223231

224-
]
232+
]

0 commit comments

Comments
 (0)