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

Saner JSON formats #354

Merged
merged 2 commits into from
Sep 30, 2024
Merged

Saner JSON formats #354

merged 2 commits into from
Sep 30, 2024

Conversation

akissinger
Copy link
Member

@akissinger akissinger commented Sep 28, 2024

Creating a PR before I merge, since this is potentially a breaking change.

Current JSON formats for proofs and rewrites have JSON containing strings containing JSON (which sometimes contain strings containing JSON containing strings containing JSON...).

Technically this works, but its a bit clunky to run the JSON parser many times to load a single file, especially if you want to consume JSON in an external tool. This branch gets rid of the nested JSON strings by splitting the old to_json method into two parts: to_dict which serialises to a python dict, then a thin wrapper to_json which just called json.dumps on the output of to_dict. Nested structures are added directly as dicts rather than strings.

The from_json will either accept a string (in which case it parses JSON first) or a python dict. Hence, ZX live can still read old-style files, but it will save in the new format.

Note this needs zxcalc/pyzx@aab09ad .

@akissinger akissinger merged commit 1635e9f into master Sep 30, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

1 participant