eclipse-ee4j / eclipse-ee4j/parsson
Merge Patch Does Not Appear to Conform to RFC7396
- Dominant language
- Java
- Stars
- 17
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
I found that when using the example in [RFC7396](https://tools.ietf.org/html/rfc7396#section-3) 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:
```
javax.json
javax.json-api
1.1.2
org.glassfish
javax.json
1.1.2
```
Contributor guide
Research direction
Start with src/main/java/com/readlearncode/mergepatch/MergePatchRFC7396.java and compare its behavior with the RFC7396 Section 3 example shown in the issue. Verify the result using the supplied Java JSON-P example; done means familyName is removed, givenName and content remain, and the other patch changes are applied as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100