Skip to content

feat!: JSON format on JSON.jl v1 instead of the deprecated JSON3.jl (JSONTag) - #468

Merged
ocots merged 4 commits into
mainfrom
feat/json-jl-v1
Oct 18, 2026
Merged

ocots merged 4 commits into
mainfrom
feat/json-jl-v1

Conversation

@ocots

@ocots ocots commented Oct 18, 2026

Copy link
Copy Markdown
Member

Closes #467.

Stacked on #463 (switching structure): both edit ext/CTModelsJSON.jl, so the base of this PR is feat/switching-structure. Once #463 is merged, the base moves to main.

What changes

JSON3.jl is deprecated in favour of JSON.jl v1. The JSON format of a Solution now uses it.

  • Dependency. JSON3 → JSON (weak dependency, test dependency, [compat], docs environment). The extension keeps its name, CTModelsJSON, which now matches its trigger.
  • Extension.
    • JSON3.read(s) → JSON.parse(s; dicttype=Dict{String,Any}): plain dictionaries, read with blob["key"]; _to_plain is no longer needed.
    • JSON3.pretty → JSON.json(...; pretty=true).
    • An export serializes first and writes after, so a value JSON cannot hold (a NaN, as before) leaves no half-written file.
  • Tag. JSON3Tag → JSONTag, and the stubs raise ExtensionError(:JSON; ...). This is a breaking change, accepted in favour of clean naming. format=:JSON is unchanged; BREAKING.md has the migration block.
  • File format. Unchanged (same keys, matrices as lists of rows).

Tests

  • New test/suite/serialization/test_json_format.jl:
    • reads two files written by the JSON3-based version (test/fixtures/json3_*.json, exported with CTModels 0.19.8: one plain solution and one with duals);
    • checks that a file written now has the same keys and shapes as the previous one (only format_version differs, as announced in feat(Solutions): switching structure of a solution; strict time grids #463);
    • round trip, NaN rejected with no file left, JSONTag replaces JSON3Tag.
  • The existing serialization tests are ported (JSON3.read/write → JSON.parse/json, JSONTag).
  • Full suite: 4738 passed, then the serialization and meta tests again after the last edits (2377 passed).
  • Docs: built in two passes; the only errors are the @extref to the CTBase.Plotting building blocks of #613 (not released yet), already there in feat(Solutions): switching structure of a solution; strict time grids #463.

Not in this PR

🤖 Generated with Claude Code

- weak dependency JSON (extension CTModelsJSON), JSON3Tag renamed JSONTag
- the extension reads with JSON.parse into plain Dicts and writes with JSON.json; an
  export serializes first, so a NaN leaves no half-written file
- the format of the files is unchanged; test_json_format.jl reads files written by the
  JSON3-based version (fixtures) and checks the keys and shapes of a file written now
- BREAKING.md with a migration block, CHANGELOG, docs

Closes #467

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Base automatically changed from feat/switching-structure to main October 18, 2026 18:50
@ocots
ocots marked this pull request as ready for review October 18, 2026 18:53
@ocots
ocots merged commit 29151b1 into main Oct 18, 2026
4 checks passed
@ocots
ocots deleted the feat/json-jl-v1 branch October 18, 2026 18:59
@ocots ocots mentioned this pull request Oct 19, 2026
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.

Replace the deprecated JSON3.jl by JSON.jl v1 (rename JSON3Tag to JSONTag)

1 participant