Skip to content

Common: dump an empty JsonObject as {} instead of null - #292

Draft
dayfine wants to merge 5 commits into
mainfrom
fix/json-empty-object-dump
Draft

dayfine wants to merge 5 commits into
mainfrom
fix/json-empty-object-dump

Conversation

@dayfine

@dayfine dayfine commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Base: main. No parent PRs; the diff shows only this change. Merged into #258 (FRLG checkpoint replay), which needs it.

JsonValue::dump() writes an empty JsonObject as null, so any document that is parsed and dumped again loses its {} values.

  • to_nlohmann() started each object as a default nlohmann::json, which stays null until a key is added. It now builds object_t, as arrays already use array_t.
  • New Common::JsonTools round-trip tests: an empty object, a nested empty object and a nested empty array must survive dump and reparse.

This was the cause of 14 of the 17 PokemonFRLG::StoryReplay failures on #258: that test re-dumps binding.json, whose "parameters": {} came back as null.

Testing

Headless runner (SerialProgramsTests) on macOS: Common::JsonTools 3/3 (the empty-object case was red before the fix), and PokemonFRLG::StoryReplay at #258 went from 3/17 to 17/17.

🤖 Generated with Claude Code

https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss

dayfine and others added 5 commits November 9, 2026 00:58
JsonValue::dump() writes an empty JsonObject as "null", so a document
re-dumped after parsing loses every "{}" and the reader sees null. This
test is red until to_nlohmann() builds objects as objects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
to_nlohmann() started each object as a default nlohmann::json, which is
null until a key is added, so an empty object came out as null. Build it
as object_t, as arrays already use array_t.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
One case per container shape, registered from a named table, so a
failure names the shape that lost its type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
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