flipkart-incubator / flipkart-incubator/zjsonpatch
Can we get the difference in both the json files
- Dominant language
- Java
- Stars
- 586
- Forks
- 153
- PR merge metrics
- No merged PRs in 30d
Description
I want to compare two jsons and if they are equal. if there is a difference , I just want to display the difference. With the JsonDiff class I can only get the difference in the current string.
please find below my code
ObjectMapper jacksonObjectMapper = new ObjectMapper();
JsonNode beforeNode = jacksonObjectMapper.readTree(jsonActual);
JsonNode afterNode = jacksonObjectMapper.readTree(jsonCurrent);
JsonPatch patch = JsonDiff.asJsonPatch(beforeNode, afterNode);
String diffs = patch.toString();
below is the output i can see
op: replace; path: "/businessServiceabilityResponse/0/serviceabilityDetail/0/serviceabilitySource"; value: "ELOC"]
Note : the current file has value as ELOC and actualfile has the value ELOC1. I would like to have have both the differences in place. Can I achieve this
Language - Java 8
Contributor guide
Research direction
The issue names JsonDiff.asJsonPatch, JsonPatch, and the beforeNode and afterNode inputs, but no repository files or tests. Start by tracing how JsonDiff creates replacement operations and how JsonPatch renders them. Done means a changed path can expose both the previous and current values, with the behavior covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100