Giter Site home page Giter Site logo

getModifiedDiff() about json-diff HOT 4 CLOSED

karam-naser avatar karam-naser commented on June 22, 2024
getModifiedDiff()

from json-diff.

Comments (4)

vearutop avatar vearutop commented on June 22, 2024

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.

karam-naser avatar karam-naser commented on June 22, 2024

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.

karam-naser avatar karam-naser commented on June 22, 2024

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.

vearutop avatar vearutop commented on June 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.