flipkart-incubator / flipkart-incubator/zjsonpatch
when compare two json field about null and empty string "", the zjsonpatch is unexcept
- Dominant language
- Java
- Stars
- 586
- Forks
- 153
- PR merge metrics
- No merged PRs in 30d
Description
`
final String newData = "{}";
final String oldData = "{\"x\": \"\"}";
JsonNode oldJson = OBJECT_MAPPER.readTree(StringUtils.isEmpty(oldData) ? "{}" : oldData);
JsonNode newJson = OBJECT_MAPPER.readTree(StringUtils.isEmpty(newData) ? "{}" : newData);
final EnumSet enumSet = EnumSet.of(DiffFlags.ADD_ORIGINAL_VALUE_ON_REPLACE);
JsonNode jsonNode = JsonDiff.asJson(oldJson, newJson, enumSet);
`
the op filed of result is: remove ----this is right.
the value filed of result is: "" -----this is not right , i think the right value is null. beacuse the "value" of result should represent new value.
Contributor guide
Research direction
Start with the JsonDiff.asJson call and the DiffFlags.ADD_ORIGINAL_VALUE_ON_REPLACE option shown in the report, then reproduce the comparison between {"x":""} and {}. Inspect existing tests and the generated remove operation to determine whether its value should represent the original or new value under the repository's RFC 6902 implementation. Done means the behavior is clarified and covered by a regression test if the report is confirmed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100