Skip to content

Commit 7fae625

Browse files
committed
Per Review: Removed JsonPatch Operations section
1 parent f331b66 commit 7fae625

File tree

1 file changed

+0
-144
lines changed

1 file changed

+0
-144
lines changed

aspnetcore/web-api/jsonpatch.md

Lines changed: 0 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -95,150 +95,6 @@ The preceding action method example calls an overload of <xref:Microsoft.AspNetC
9595
}
9696
```
9797

98-
## JSON Patch Operations
99-
100-
The following sections describe the supported JSON Patch operations `add`, `remove`, `replace`, `move`, `copy`, and `test` that modify a JSON document and provide examples of their usage.
101-
102-
### The `add` Operation
103-
104-
* If `path` points to an array element: Inserts a new element before the one specified by `path`.
105-
* If `path` points to a property: Sets the property value.
106-
* If `path` points to a nonexistent location:
107-
* If the resource to patch is a static object: The request fails.
108-
109-
Example:
110-
111-
```json
112-
[
113-
{
114-
"op": "add",
115-
"path": "/customerName",
116-
"value": "Barry"
117-
},
118-
{
119-
"op": "add",
120-
"path": "/orders/-",
121-
"value": {
122-
"orderName": "Order2",
123-
"orderType": null
124-
}
125-
}
126-
]
127-
```
128-
129-
### The `remove` Operation
130-
131-
* If `path` points to an array element**: Removes the element.
132-
* If `path` points to a property**:
133-
* If the resource to patch is a static object:
134-
* If the property is nullable: Sets it to `null`.
135-
* If the property is non-nullable: Sets it to `default<T>`.
136-
137-
Example:
138-
139-
```json
140-
[
141-
{
142-
"op": "remove",
143-
"path": "/customerName"
144-
},
145-
{
146-
"op": "remove",
147-
"path": "/orders/0"
148-
}
149-
]
150-
```
151-
152-
### The `replace` Operation
153-
154-
This operation is functionally the same as a `remove` followed by an `add`.
155-
156-
Example:
157-
158-
```json
159-
[
160-
{
161-
"op": "replace",
162-
"path": "/customerName",
163-
"value": "Barry"
164-
},
165-
{
166-
"op": "replace",
167-
"path": "/orders/0",
168-
"value": {
169-
"orderName": "Order2",
170-
"orderType": null
171-
}
172-
}
173-
]
174-
```
175-
176-
### The `move` Operation
177-
178-
* If `path` points to an array element**: Copies from the element at `from` to the location specified by `path`, then removes the element at `from`.
179-
* If `path` points to a property**: Copies the value of the `from` property to the `path` property, then removes the `from` property.
180-
* If `path` points to a nonexistent property**:
181-
* If the resource to patch is a static object: The request fails.
182-
183-
Example:
184-
185-
```json
186-
[
187-
{
188-
"op": "move",
189-
"from": "/orders/0/orderName",
190-
"path": "/customerName"
191-
},
192-
{
193-
"op": "move",
194-
"from": "/orders/1",
195-
"path": "/orders/0"
196-
}
197-
]
198-
```
199-
200-
### The `copy` Operation
201-
202-
This operation is functionally the same as a `move` operation without the final `remove` step.
203-
204-
Example:
205-
206-
```json
207-
[
208-
{
209-
"op": "copy",
210-
"from": "/orders/0/orderName",
211-
"path": "/customerName"
212-
},
213-
{
214-
"op": "copy",
215-
"from": "/orders/1",
216-
"path": "/orders/0"
217-
}
218-
]
219-
```
220-
221-
### The `test` Operation
222-
223-
* If the value at the location indicated by `path` is different from the value provided in `value`, the request fails. In that case, the entire PATCH request fails, even if all other operations in the patch document would otherwise succeed.
224-
225-
Example:
226-
227-
```json
228-
[
229-
{
230-
"op": "test",
231-
"path": "/customerName",
232-
"value": "Nancy"
233-
},
234-
{
235-
"op": "add",
236-
"path": "/customerName",
237-
"value": "Barry"
238-
}
239-
]
240-
```
241-
24298
## Apply a JSON Patch document to an object
24399

244100
The following examples demonstrate how to use the <xref:Microsoft.AspNetCore.JsonPatch.JsonPatchDocument.ApplyTo(System.Object)> method to apply a JSON Patch document to an object.

0 commit comments

Comments
 (0)