Repository navigation
Description
Part of #138
Popularity: 1/7 corpus consumers (slang-server)
Related issues
- Related fork issues: Map (Lane 2): JSON / RPC & Format Interop #86 (
Map (Lane 2): JSON / RPC & Format Interop), Build/CMake: reflectcpp target lacks SYSTEM headers, warning/visibility/PIC/linter isolation, and collides on bundled yyjson #140 (leaking bundledyyjsonimplementation details).
Observed Downstream Workaround (hudson-trading/slang-server @ 1b413a46)
rfl::json exposes rfl::json::pretty (4-space indentation) but provides no named rfl::json flag constants for 2-space pretty-printing or JSONC-style reading (comments + trailing commas). As a result, slang-server reaches directly into raw yyjson C macros (YYJSON_READ_ALLOW_COMMENTS, YYJSON_READ_ALLOW_TRAILING_COMMAS, YYJSON_WRITE_PRETTY_TWO_SPACES) across 6 files / 10 call sites — even bitwise-ORing an rfl::json constant with a raw yyjson macro:
src/Config.cpp#L21:static int CONFIG_READ_FLAGS = YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS;
src/gen_config_main.cpp#L43:std::cout << rfl::json::write(schema, rfl::json::pretty | YYJSON_WRITE_PRETTY_TWO_SPACES) << '\n';
src/SlangServer.cpp#L929-L930,#L953,#L983-L984,#L1241:auto generic = rfl::json::read<rfl::Generic>( jsonstr, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS); ... out << rfl::json::write(rfl::Generic(obj), YYJSON_WRITE_PRETTY_TWO_SPACES);
include/util/Logging.h#L28-L31:rfl::json::write<rfl::UnderlyingEnums>(some_struct, YYJSON_WRITE_PRETTY_TWO_SPACES)tests/cpp/utils/GoldenTest.h#L180andtests/cpp/ConfigTests.cpp#L1142: both passYYJSON_WRITE_PRETTY_TWO_SPACES.
Root Cause & Suggested Direction
rfl::json forwards an opaque yyjson_read_flag / yyjson_write_flag bitmask while only wrapping rfl::json::pretty in the rfl::json namespace. Consumers wanting common config-file ergonomics (JSONC comments, trailing commas, 2-space pretty output) must depend directly on <yyjson.h> C macros.
Expose first-class rfl::json flag constants (e.g., rfl::json::pretty_two_spaces, rfl::json::allow_comments, rfl::json::allow_trailing_commas, or rfl::json::jsonc) so downstream code stays backend-agnostic.
Upstream Overlap
- Feature request: Support jsonc parsing munich-data-engineering/reflect-cpp#404 (closed/wontfix on wrapper API; resolved via raw flags) — User requested JSONC support via a processor (
rfl::Comments/rfl::JsonC); maintainer@liuzicheng1987replied "I like the idea of just using the YYJSON flag" and closed#404once rawyyjson_read_flagforwarding landed in add optional yyjson_read_flag symmetric to the yyjson_write_flag, so that non standard json's can be both written and read munich-data-engineering/reflect-cpp#374 and Allow passing yyjson flags in the read(istream) method munich-data-engineering/reflect-cpp#425 (merged, partial). - Unfiled upstream: First-class
rfl::jsonflag constants wrappingYYJSON_READ_ALLOW_COMMENTS,YYJSON_READ_ALLOW_TRAILING_COMMAS, andYYJSON_WRITE_PRETTY_TWO_SPACES.
Activity
[-]API/JSON (slang-server): rfl::json lacks JSONC read flags and 2-space pretty-print, leaking raw YYJSON_* macros across 6 files[/-][+]API/JSON: rfl::json lacks JSONC read flags and 2-space pretty-print, leaking raw YYJSON_* macros across 6 files[/+]clockblocker commentedon Nov 29, 2026
Tracking & PR Cross-Reference
Status: Fully addressed in
upstream-queue(Draft PR #209).rfl::jsonread and write flag constants) → queued in Draft PR Upstream PR Queue (sorted by mergeability score) #209 as Rank Emit oneOf for rfl::TaggedUnion in JSON schema, add VariantsAsOneOf #14 (commit95c6caae, score 85/100; exposes version-guardedinline constexprrfl::json::read_*andrfl::json::write_*constants so consumers stop leaking rawYYJSON_*macros).