Repository navigation
Write JSON.LazyValue as its materialized value - #491
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #491 +/- ##
==========================================
+ Coverage 92.50% 92.51% +0.01%
==========================================
Files 7 7
Lines 1894 1897 +3
==========================================
+ Hits 1752 1755 +3
Misses 142 142 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JSON.json on a LazyValue never worked: lazy objects threw
"Value returned from `StructUtils.lowerkey` must be a string or real
number: JSON.PtrString", and lazy scalars were written as JSON strings
(JSON.lazy("1") wrote "1" with quotes; null wrote "nothing").
The writer had no case for LazyValue. Lazy objects and arrays were
walked with the lazy applyeach, which passes raw PtrString keys and
unmaterialized values (what parsing wants), and lazy scalars fell
through to a _string fallback that quoted the parsed value.
Write a LazyValue as its default materialization x[], lowered with the
write style, so JSON.json(x) matches JSON.json(x[]) for every write
option. json! handles a root lazy value; WriteClosure handles nested
ones before its omit_null/omit_empty checks. This isn't a
StructUtils.lower method because StructUtils.make also calls lower on
the lazy source it parses from.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quinnj
force-pushed
the
jq/write-lazyvalue
branch
from
September 28, 2026 18:18
4acd6b3 to
893037a
Compare
Retain the writer fix with current error-context and byte-vector output APIs. AI disclosure: This work was prepared with assistance from OpenAI Codex. Co-authored by Codex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JSON.json(JSON.lazy("{\"a\":1}"))throws on a lazy object key, while lazy numbers andnullare written as strings. Write a lazy value as its parsed value at the root and inside another container. Materialize nested values before the omission checks soomit_nullandomit_emptysee the actual value.Keep this normalization in the writer: adding a general lowering method would also materialize sources used by typed parsing. Output follows ordinary parsed-value writing, including whitespace, key normalization, duplicate-key handling, custom styles, pretty printing, and byte-vector output. No exports or dependencies are added.
Validation: the 44 permanent regressions pass, and full suites pass on Julia 1.10.12 and 1.13.1, including current trim compile tests. An independent 1180-assertion comparison passes on each version across scalars, objects, arrays, nested containers, seven option/style combinations, string/pretty/byte-vector output, typed parsing, and error propagation. Ten focused checks on unchanged master give 2 passing, 4 failing, and 4 errored results. Current master is integrated without conflicts or a force push; all twelve hosted checks pass, including the Parsers 2.8.8/3 matrix, docs, and both coverage checks. The stable upload was accepted for this exact JSON.jl head.
AI disclosure: This work was prepared with assistance from OpenAI Codex.
Co-authored by Codex
Original change generated with Claude Code.