toJson5

fnstring toJson5(const ref CdmDocument doc, Json5WriteOptions opts = Json5WriteOptions.init) @safe

Serialize a CDM document to JSON5 text.

Preserves comments attached to nodes in the output.

Parameters

docThe document to serialize.
optsWriter options (indentation, etc.).

Returns

JSON5 text representation.

Example:

auto doc = parseJson5Cdm(`{// comment\nkey: "value"}`);
string output = toJson5(doc);
assert(output.canFind("// comment"));