Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff only structure, ignore (leaf?) values #58

Open
wasker opened this issue Jul 21, 2023 · 2 comments
Open

Diff only structure, ignore (leaf?) values #58

wasker opened this issue Jul 21, 2023 · 2 comments

Comments

@wasker
Copy link

wasker commented Jul 21, 2023

My use case is to compare JSON files with localized data. These files have specific structure and I need to ensure that all locales follow the same structure.

E.g., these are the same:

{
    "qwe": {
        "asd": {
            "label": "something",
            "url": "http://blah.com"
        }
    }
}

{
    "qwe": {
        "asd": {
            "label": "lorem ipsum",
            "url": "http://blah.lorem"
        }
    }
}

These are not the same:

{
    "qwe": {
        "asd": {
            "label": "something",
            "target": "_blank",
            "url": "http://blah.com"
        }
    }
}

{
    "qwe": {
        "asd": {
            "label": "lorem ipsum",
            "url": "http://blah.lorem"
        },
        "zxc": {
            "button": "yadda"
        }
    }
}

Would that be possible/feasible to accommodate with this tool?

@josephburnett
Copy link
Owner

There are a few similar requests. One for defining equality with a regular expression and one to ignore floating point rounding errors. So it would be worth considering how we can address in general the problem of defining equality constraints.

Yes, this cool could be modified to ignore the actual leaf values. But I wonder if a schema validator would be a better fit. Is the structure known ahead of time? If you can define the shape ahead of time with JSON Schema then determining if the files have the right structure is just schema validation.

@wasker
Copy link
Author

wasker commented Jul 29, 2023

Thanks for suggestions. Unfortunately, there's no schema for these files and there're lots of these files to even attempt produce schema by hand. I was hoping that short-circuiting the diffing logic I could get this done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants