Skip to content

Add rfl::json::Raw for passthrough raw JSON subtrees - #67

Open
clockblocker wants to merge 2 commits into
mainfrom
json-raw
Open

clockblocker wants to merge 2 commits into
mainfrom
json-raw

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs munich-data-engineering#368 (addresses the JSON-RPC passthrough params/result/data use case without converting through rfl::Generic).

Adds rfl::json::Raw so structs parsed/written with rfl::json can carry arbitrary unparsed JSON subtrees verbatim without converting through intermediate rfl::Generic DOM trees.

Changes

  • include/rfl/json/Raw.hpp (included via include/rfl/json.hpp):
    • rfl::json::Raw holding a raw JSON string (default-initialized to "null"), with constructors from std::string, std::string_view, const char*, accessors (str(), value(), c_str(), empty()), defaulted operator==, and from_json_obj using yyjson_val_write with RAII std::free cleanup.
    • rfl::parsing::Parser<json::Reader, json::Writer, json::Raw, ProcessorsType> specialization supporting root values, struct fields, std::optional, std::vector, std::map, and rfl::json::to_schema.
  • include/rfl/json/Writer.hpp & src/rfl/json/Writer.cpp:
    • Added raw_as_root, add_raw_to_array, and add_raw_to_object using yyjson_mut_rawncpy (falling back to yyjson_mut_null if empty).
  • tests/json/test_raw.cpp:
    • Unit tests for root values, struct fields, optionals (missing, null, present), vectors/maps, verbatim passthrough without re-parsing, rfl::json::pretty, and rfl::json::to_schema.

Verification

  • Built with Ninja (-Wall -Werror) and ran ctest: 589/589 tests pass (including all 7 new json.test_raw_* tests).

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