Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
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

Adds rfl::json::Raw so structs read and written with rfl::json can carry arbitrary unparsed JSON subtrees verbatim without round-tripping through rfl::Generic. Purely additive.

Refs munich-data-engineering#368.

Example

struct RpcRequest {
  std::string method;
  rfl::json::Raw params;  // kept verbatim, e.g. R"({"id":1,"flags":[true]})"
};

auto req = rfl::json::read<RpcRequest>(input).value();
std::string_view raw_params = req.params.str();
std::string out = rfl::json::write(req);  // embeds raw_params directly

Key details

  • Default-initializes to "null", constructs from std::string / std::string_view / const char*, and exposes str(), value(), c_str(), empty(), and operator==.
  • Reads via yyjson_val_write (with RAII std::free cleanup) and writes via yyjson_mut_rawncpy (falling back to null if empty).
  • Works as a root value, struct field, or inside std::optional, std::vector, std::map, and rfl::json::to_schema.

AI-authored.

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