Comments (4)
getModifiedDiff()
is expected to return a list of paths that exist in both JSON documents with different values.
In your example second document does not seem to modify any value existing in first document, but rather adds new values.
Maybe you need to use getAdded()
or getAddedPaths()
instead of getModifiedDiff()
in this case.
Here is getPatch()
from first to second document:
[
{
"value": "",
"op": "add",
"path": "/output/0/upload"
},
{
"value": "a0vA206.mp4",
"op": "add",
"path": "/answers/0/upload"
},
{
"value": "",
"op": "add",
"path": "/answers/0/image"
},
{
"value": "a0vA207.mp4",
"op": "add",
"path": "/answers/1/upload"
},
{
"value": "",
"op": "add",
"path": "/answers/1/image"
},
{
"value": "",
"op": "add",
"path": "/answers/2/upload"
},
{
"value": "",
"op": "add",
"path": "/answers/2/image"
},
{
"value": "",
"op": "add",
"path": "/answers/3/upload"
},
{
"value": "",
"op": "add",
"path": "/answers/3/image"
},
{
"value": "",
"op": "add",
"path": "/question/0/upload"
}
]
Does this help your issue?
from json-diff.
thanks for your answer
if you look at answers you see the difference
1st json:
answers": [{"text": "ـم", "correct": true}, {"text": "م", "correct": false}, {"text": "ـمـ", "correct": false}, {"text": "مـ", "correct": false}], "question": [{"text": "قَلَـ....", "type": "text", "translation": ""}],
2nd json:
"answers":[{"text":"\u0640\u0645","correct":true,"upload":"a0vA206.mp4","image":""},{"text":"\u0645","correct":false,"upload":"a0vA207.mp4","image":""},{"text":"\u0640\u0645\u0640","correct":false,"upload":"","image":""},{"text":"\u0645\u0640","correct":false,"upload":"","image":""}]
the bolded section not exist in the one
from json-diff.
i've made a function to delete null values from both JSONs and then call getPatch() and it's worked now.
I can find if there's any difference between them
from json-diff.
the bolded section not exist in the one
Yes, and because of that these sections do not contribute to getModifiedDiff()
, they are additions, not modifications (in terms of JsonDiff
).
from json-diff.
Related Issues (20)
- Implement merge diff/patch
- Warning: A non-numeric value encountered HOT 1
- Library only works with stdClass not with associative arrays HOT 4
- JsonDiff from dictionary like array, getting duplicated path removal operations HOT 6
- Deprecated dependencies HOT 2
- Remove last elemnt followed by add converting to associative array HOT 1
- Difference ignoring order of elements in an array. HOT 11
- Thank you 👍 HOT 1
- Issue with comparing arrays HOT 2
- Invalid key for array operation HOT 1
- Wrong indexes of removed array items HOT 1
- Removing an item from the array when option REARRANGE_ARRAYS is enabled HOT 2
- Enhancement: Include failed operation in Exception HOT 2
- Question: Visualise the difference
- getPatch with REARRANGE_ARRAYS is not returning the correct paths when items are removed from an array HOT 1
- Class "Swaggest\JsonDiff\JsonDiff" not found HOT 1
- Improve JsonPatch exceptions HOT 1
- Add option for exclute test operation
- Unwanted count() exception in JsonPointer.php
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-diff.