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

Support JSON inputs too #12

Closed
simonw opened this issue Feb 22, 2021 · 3 comments
Closed

Support JSON inputs too #12

simonw opened this issue Feb 22, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Feb 22, 2021

I find myself wanting to generate commit messages for JSON files.

This can reuse almost all of the logic from csv-diff - so for the moment I'm going to add that ability here rather than spin up a brand new tool.

A rename if this tool can come later!

@simonw simonw added the enhancement New feature or request label Feb 22, 2021
@simonw
Copy link
Owner Author

simonw commented Feb 23, 2021

Annoyingly the --json flag is already being used for "output as JSON".

@simonw
Copy link
Owner Author

simonw commented Feb 23, 2021

I can use --format=json instead (already has --format=csv and --format=tsv).

@simonw
Copy link
Owner Author

simonw commented Feb 23, 2021

Had to add special treatment for nested lists and objects - they get serialized to a JSON string and compared that way.

Example output:

% csv-diff locations.json locations-updated.json --format json --key id       
3 rows changed

  id: rec00SICtL8KJiLim
    Appointment scheduling instructions: "["https://www.riteaid.com/pharmacy/covid-qualifier"]" => "["https://www.riteaid.com/pharmacy/covid-qualifier", "blah 2"]"

  id: rec05xrPZ4b7dCDns
    Location Type: "Pharmacy" => "Pharmacy 2"

  id: rec0IOCI2WsksvXef
    Name: "WALMART PHARMACY 10-3477" => "WALMART PHARMACY 10-347"

@simonw simonw closed this as completed in 328718f Feb 23, 2021
simonw added a commit that referenced this issue Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant