Questions tagged [json-patch]

JSON Patch defines the media type "application/json-patch", a JSON document structure for expressing a sequence of operations to apply to a JSON document

  1. Introduction

    JavaScript Object Notation (JSON) [RFC4627] is a common format for the exchange and storage of structured data. HTTP PATCH [RFC5789] extends the Hypertext Transfer Protocol (HTTP) [RFC2616] with a method to perform partial modifications to resources.

    JSON Patch is a format (identified by the media type "application/ json-patch") for expressing a sequence of operations to apply to a target JSON document, suitable for use with the HTTP PATCH method.

    This format is also potentially useful in other cases where necessary to make partial updates to a JSON document, or to a data structure that has similar constraints (i.e., they can be serialised as an object or an array using the JSON grammar).

  2. Conventions

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119].

    See Section 5 for information about handling errors.

  3. Document Structure

    A JSON Patch document is a JSON [RFC4627] document that represents an array of objects. Each object represents a single operation to be applied to the target JSON document.

    An example JSON Patch document, transferred in a HTTP PATCH request:

    PATCH /my/data HTTP/1.1 Host: example.org Content-Length: 326 Content-Type: application/json-patch If-Match: "abc123"

    [ { "op": "test", "path": "/a/b/c", "value": "foo" }, { "op": "remove", "path": "/a/b/c" }, { "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] }, { "op": "replace", "path": "/a/b/c", "value": 42 }, { "op": "move", "from": "/a/b/c", "path": "/a/b/d" }, { "op": "copy", "from": "/a/b/d", "path": "/a/b/e" } ]

Bryan & Nottingham Expires July 24, 2013 [Page 3]

Internet-Draft JSON Patch January 2013

Evaluation of a JSON Patch document begins against a target JSON document. Operations are applied sequentially in the order they appear in the array. Each operation in the sequence is applied to the target document; the resulting document becomes the target of the next operation. Evaluation continues until all operations are successfully applied, or an error condition is encountered. Sources:

http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-10

191 questions
0
votes
1 answer

SQLAlchemy / jsonpatch - how to make patch paths case-insensitive?

I've been trying to find some documentation for jsonpatch==1.16 on how to make PATCH paths case-insensitive. The problem is that: PATCH /users/123 [ {"op": "add", "path": "/firstname", "value": "Spammer"} ] Seems to mandate that the DB (MySQL /…
Juha Untinen
  • 1,806
  • 1
  • 24
  • 40
0
votes
1 answer

jQuery PATCH request not recognised by Marvin.JsonPatch

I'm trying to send an AJAX PATCH request to a Web API method and have the patched object recognised by Marvin.JsonPatch. So far, everything I've sent to the server has resulted in an empty request being received. The Web API controller method looks…
awj
  • 7,482
  • 10
  • 66
  • 120
0
votes
0 answers

Golang , Couchbase updating sub document and finding json path

What is the best approach to update sub document in couchbase ? I am taking about nested json documents . Simple fields are easily updatable using syntax like set name = 'Jon Doe' but what about nested json document . I have read all the pages in…
sh0umik
  • 1,549
  • 2
  • 17
  • 27
0
votes
0 answers

Can not deserialize instance of java.util.ArrayList out of FIELD_NAME token

I have seen others with this same error, but it has been caused by something else so none of the responses have helped me. I have a class called Diff: public class Diff { private String path; private String value; private Operation…
user2869231
  • 1,431
  • 5
  • 24
  • 53
0
votes
1 answer

c# json force patch

Let's say there an empty is JSON object: String obj1 = "{}"; Is there a way to patch update it and force creation of missing path using C#? So after patch like this: { "op": "add", "path": "/a/b", "value": "foo" }, the result will be: { a: { b:…
Serhiy
  • 4,357
  • 5
  • 37
  • 53
0
votes
1 answer

Description format for partial uploads of byte data using HTTP PATCH method

I want to use the HTTP PATCH method to add possibility of partial uploads to my REST interface. I found the JSON Patch Format and the XML Patch Operation Framework which are used to update (and extend) existing JSON and XML resources via PATCH…
Sebastian Barth
  • 4,079
  • 7
  • 40
  • 59
0
votes
2 answers

How to store json-patch operations in redis queue and guarantee their consistency?

I have collaborative web application that handles JSON-objects like the following: var post = { id: 123, title: 'Sterling Archer', comments: [ {text: 'Comment text', tags: ['tag1', 'tag2', 'tag3']}, {text: 'Comment test', tags:…
Erik
  • 14,060
  • 49
  • 132
  • 218
-1
votes
1 answer

http patch method - single oparation for each element of array

In my React application, I'm using useForm to sending my forms. When I'm using the PATCH method and sending to API a value (array): participants.push({ participant_id: person, place_id: place }); then my PATCH request looks like this: { …
-1
votes
1 answer

Add item to JSON array using JsonPatchDocument

I am trying to add an element to a JSON array using Microsoft's JsonPatch implementation in .NET 6: JSON input: { "foo": [ 1 ] } Expected JSON output: { "foo": [ 1, 2 ] } Following their documentation, I ended up with the following code: string…
Maxime Rossini
  • 3,612
  • 4
  • 31
  • 47
-1
votes
1 answer

Using params with oc patch comand

Trying to write an sh script with several oc patch commands and need to parametrize several values. Now script looks like: oc patch svc svc-ingressgateway --type='json' -p='[{"op": "add", "path": "/spec/ports/-", "value": {"name":…
1 2 3
12
13