brbzull0 commented on code in PR #13609:
URL: https://github.com/apache/trafficserver/pull/13609#discussion_r3948930572
##########
include/tsutil/YamlCfg.h:
##########
@@ -39,6 +39,26 @@ namespace Yaml
constexpr std::string_view YAML_BOOL_TAG_URI{"tag:yaml.org,2002:bool"};
constexpr std::string_view YAML_NULL_TAG_URI{"tag:yaml.org,2002:null"};
+ // Put an emitter into JSON output mode.
+ //
+ // yaml-cpp has no JSON output mode. The nearest equivalent is flow style
with every scalar double quoted. For the
+ // node shapes the callers here emit -- maps, sequences, scalars and nulls,
carrying no tags, anchors or aliases --
+ // that is JSON-compatible except for null: yaml-cpp writes `~`, which JSON
parsers reject. LowerNull writes the
+ // literal `null` instead. YAML resolves `~` and `null` to the same value,
so the output still reads as YAML.
+ //
Review Comment:
Good catch, reworded in 86119e63f.
The guarantee is now stated as "parses as JSON", and a paragraph names the
limitation outright: `DoubleQuoted` quotes every scalar, so numbers and
booleans arrive as strings -- `"12"` rather than `12`, `"true"` rather than
`true`. A consumer validating against a schema that declares `integer` or
`boolean` will reject that, and no manipulator here changes it. Preserving
scalar types needs a real JSON serializer rather than a yaml-cpp emitter.
Fixing the typing itself stays out of scope here, as noted in the PR
description -- it needs its own design decision.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]