Add JSON output support to Emboss text format#237
Open
AaronWebster wants to merge 1 commit into
Open
Conversation
reventlov
reviewed
Dec 3, 2025
AaronWebster
force-pushed
the
text-output-json
branch
from
June 2, 2026 20:43
f29478b to
2db643d
Compare
AaronWebster
force-pushed
the
text-output-json
branch
3 times, most recently
from
July 16, 2026 23:33
f3d6098 to
b74c57e
Compare
Add a `json` mode to TextOutputOptions so any view can be serialized as JSON, e.g. `WriteToString(view, TextOutputOptions().Json(true))`: - Field names are quoted and values are comma-separated; comments are suppressed. Compact output by default; multiline JSON places each field on its own indented line. - Enums serialize as quoted names (or bare numbers when the value has no name); bool as true/false; NaN and Infinity as quoted strings. - comments(), digit_grouping(), and numeric_base() automatically return JSON-appropriate values when json() is set, so callers don't have to special-case JSON throughout. - Integers wider than 32 bits -- and the numeric form of unnamed enum values whose underlying type is wider than 32 bits -- are serialized as quoted strings by default (JsonLargeIntegerHandling::kLargeAsString), avoiding silent precision loss in JSON parsers that treat all numbers as IEEE-754 doubles. JsonLargeIntegerHandling::kAsNumber opts back into raw numeric output for consumers that preserve full 64-bit integers. Adds JsonTestEnum/JsonTestArrayStruct/JsonTestStruct/JsonEnumStruct/ JsonFloatStruct fixtures to testdata/text_format.emb and coverage in text_format_test.cc and emboss_array_view_test.cc (compact and multiline output, skipped fields, large-integer and unnamed-enum handling, and NaN/Infinity). Regenerates the C++ goldens.
AaronWebster
force-pushed
the
text-output-json
branch
from
July 16, 2026 23:43
b74c57e to
fcc0223
Compare
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.
Add JSON output support to Emboss text format