Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Patch Does Not Appear to Conform to RFC7396 #14

Open
glassfishrobot opened this issue Feb 6, 2018 · 3 comments
Open

Merge Patch Does Not Appear to Conform to RFC7396 #14

glassfishrobot opened this issue Feb 6, 2018 · 3 comments

Comments

@glassfishrobot
Copy link

I found that when using the example in RFC7396 that I get different results.

Given the JSON document:

   {
     "title": "Goodbye!",
       "author" : {
       "givenName" : "John",
       "familyName" : "Doe"
     },
     "tags":[ "example", "sample" ],
     "content": "This will be unchanged"
   }

and the patch:

   {
     "title": "Hello!",
     "phoneNumber": "+01-123-456-7890",
     "author": {
       "familyName": null
     },
     "tags": [ "example" ]
   }

and the Json Patch code:

JsonValue source = Json.createValue("{\"title\":\"Goodbye!\",\"author\":{\"givenName\":\"John\",\"familyName\":\"Doe\"},\"tags\":[\"example\",\"sample\"],\"content\":\"This will be unchanged\"}");
JsonValue patch = Json.createValue("{\"title\":\"Hello!\",\"phoneNumber\":\"+01-123-456-7890\",\"author\":{\"familyName\":null},\"tags\":[\"example\"]}");

JsonMergePatch jsonMergePatch = Json.createMergePatch(patch);
JsonValue jsonValue = jsonMergePatch.apply(source);
System.out.println(jsonValue);

The output is:

        {
          "title": "Hello!",
          "phoneNumber": "+01-123-456-7890",
          "author": {
            "familyName": null
          },
          "tags": [
            "example"
          ]
        }

but should be:

       {
         "title": "Hello!",
         "author" : {
           "givenName" : "John"
         },
         "tags": [ "example" ],
         "content": "This will be unchanged",
         "phoneNumber": "+01-123-456-7890"
       }
  1. The author array contents have been replaced with "familyName": null when the operation should have only removed the familyName element.
  2. The content element has been removed. It should not have been touched.

Source code here: https://github.com/readlearncode/Java-EE-8-Only-Whats-New/blob/master/Java-API-for-JSON-Processing-1-1-JSR374/src/main/java/com/readlearncode/mergepatch/MergePatchRFC7396.java

There are the Maven coords:

    <dependencies>
        <dependency>
            <groupId>javax.json</groupId>
            <artifactId>javax.json-api</artifactId>
            <version>1.1.2</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.json</artifactId>
            <version>1.1.2</version>
        </dependency>
    </dependencies>
@glassfishrobot
Copy link
Author

@keilw Commented
Thanks. It sounds like a bug. @m0mus, @lukasj I strongly suspect, these kinds of things also require another MR here, not just fixing it in EE4J, or do you have another opinion?

@glassfishrobot
Copy link
Author

@m0mus Commented
Why do you think that MR is required? I don't think so. API change is not
needed in order to fix this.

9 февр. 2018 г. 14:25 пользователь "Werner Keil" [email protected]
написал:

Thanks. It sounds like a bug. @m0mus https://github.com/m0mus, @lukasj
https://github.com/lukasj I strongly suspect, these kinds of things
also require another MR here, not just fixing it in EE4J, or do you have
another opinion?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/javaee/jsonp/issues/77#issuecomment-364432805, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AI6RHR1Zd-RqIqBJQMe-qa2n8kgp7bBEks5tTEdBgaJpZM4R7jz7
.

@glassfishrobot
Copy link
Author

@lukasj lukasj transferred this issue from jakartaee/jsonp-api Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant