#include "fson/FsonWriter.hh"
The pretty-printing serializer.
| Member | Description |
|---|---|
enum class Dialect { Fson, Json, Json5 } | output dialect, default Fson — see dialects |
setDialect(Dialect) / getDialect() | |
enum class DisabledMemberPolicy { ConvertToComment, Keep, Drop } | -- members in the Json / Json5 dialects, default ConvertToComment; no effect on Fson — see DisabledMemberPolicy |
setDisabledMemberPolicy(...) / getDisabledMemberPolicy() | |
setKeepDisabledMembers(bool) / getKeepDisabledMembers() | deprecated shim: true ↔ Keep, false ↔ ConvertToComment |
setPreferBareKeys(bool) / getPreferBareKeys() | Fson / Json5: write quoted keys bare wherever the name grammar allows; no effect on Json |
write(document, std::ostream&) | serialize to a stream; dispatches on the root value's actual type |
write(document) → std::string | serialize to a string |
writeFile(document, filename) → bool | false on I/O failure |
static encodeString(text) → std::string | string escaping without the quotes; valid in all three dialects |
FsonWriter w;
w.setDialect( FsonWriter::Dialect::Json5 );
w.setPreferBareKeys( true );
std::string json5 = w.write( *doc );
The default Fson dialect is what Fson::save uses.

