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
1
vote
0 answers

I am comparing two JavaScript objects using jsonpatch.compare method and making a patch call

If one property value of both objects is same it setting to null or empty, but I don't want to set anything if both property values are same. How do I do that? obj1 = { name: 'red', age: 12 } obj2 = { name: 'yellow' age: 12…
1
vote
1 answer

Like expression in JSON Path

I have a JOSN some thing like this { "Room" :{ "Book" : { "name" : "abc" }, "Book1": { "name" : "xyz" }, "Book3": { "name" : "abc123" }, "Tv" : { "name" : "zyc" …
1
vote
0 answers

How to apply JSON patch document on the class containing interface type collection

I have following code: public class Customer { public string CustomerName { get; set; } [JsonConverter(typeof(ConcreteConverter))] public List Orders { get; set; } } public class Order…
Pankaj Kaushik
  • 127
  • 2
  • 11
1
vote
1 answer

JsonPatchDocument parm is null on entering API using a flurl client

I'm using Flurl to call my .net core 3.1 API, but the JsonPatchDocument parm is null on entering the API. I can call this same API with HttpClient, and it works fine, but I'm trying to stick with flurl since my other get/put/delete API calls all…
1
vote
0 answers

Get jsondiffpatch without oldvalues

Im using jsondiffpatch.net to create a patch to keep track of differences between two json objects. I do not require using the reverse and unpatch methods which makes use of the "oldValue" in the patches generated. Is there a way to display only new…
1
vote
1 answer

Can JsonPatchDocument use Attributes

Can I use Attributes on my objects and still use JsonPatchDocument? Currently, if I have this object: public class Test { public float FloatTest { get; set; } } I can only send in float, both in a post-request and in a patch-request. If I…
user2687506
  • 789
  • 6
  • 21
1
vote
1 answer

Spring JSON Patch unable to update nested Map object

in my application I'm trying to support JSON patch requests to apply partial update my entities and I'm using directly the implementation of Patch provided by Spring in the spring-data-rest library. I'm not able to use the Spring Patch…
Kerruba
  • 1,779
  • 1
  • 17
  • 25
1
vote
0 answers

PATCH Request fails for one endpoint, but does work for other endpoints

I'm a bit new to testing and am working on editing tests for a MEAN-stack web app generated by the yeoman angular-fullstack generator. I've POSTed a dummy object into my mongo database and can see the object and its ID through the mongo shell. I…
1
vote
1 answer

Why is my PATCH request empty in an ASP.NET Controller?

I have the following ASP.net Core Controller: [ApiVersion(ApiConstants.Versions.V1)] [Route(RouteConstants.ApiControllerPrefix + "/tenants/" + RouteConstants.TenantIdRegex + "/entities")] public class EntityController { [HttpPatch] …
Kzryzstof
  • 7,688
  • 10
  • 61
  • 108
1
vote
1 answer

Spring Data Rest json-patch+json on collection item with index greater than 9

The entity Parent has a collection of Item objects. Whenever I try to run a json-patch+json request that contains an operation against a collection item with an index greater than 9 Spring throws the following exception: Caused by:…
1
vote
1 answer

how to apply generic json-patch operation via neo4j or apoc

Is there a fancy or tricky way to apply an arbitrary array of jsonpatch-like to maps with cypher or even apoc? So if i have a map {a: 0, b: 0, c: 0} a collection of operations encoded in maps, say [{replace: "a", value: 1}, {replace: "b", value:…
tscherg
  • 1,032
  • 8
  • 22
1
vote
1 answer

How to create a new JsonPatchDocument in typescript?

I am try to create a new JsonPatchDocument as below , let PatchDoc = new JsonPatchDocument(); But Above is not possible as JsonPatchDocument is a interface in typescript. Can anyone help how can this be done ??? I created using let PatchDoc :…
Anusha B
  • 95
  • 1
  • 1
  • 8
1
vote
1 answer

Missing bridge between JSON-B and JSON APIs?

I'm trying to implement a function that applies a JSON-PATCH (RFC 6902) to an object annotated with JSON-B. I've come to the following solution: /** * Applies a JSON patch to a JSON-B annotated object, and returns a resulting patched version of the…
Stéphane Appercel
  • 1,427
  • 2
  • 13
  • 21
1
vote
1 answer

HTTP PATCH a joined table?

The RFC 6902 defines a lot of things and clearly. Except two related things: How do you patch a table that is joined to the resource? And when the join has multiple rows? Eg. GET /news/123 [ {"title": "Hello", "contents": "World",…
Juha Untinen
  • 1,806
  • 1
  • 24
  • 40
1
vote
0 answers

JSON Patch - Document synchronization between client and server

We have a complex JSON document. We currently manage changes with GET/POST operations involving the entire document. We would like to stop sending the entire document back and forth, so we are looking into JSON Patch. There are libraries to…
jparram
  • 804
  • 8
  • 24