yyjson
yyjson copied to clipboard
[FEAT] Generate minimal JSON5 result
Is your feature request related to a problem? Please describe. We introduced JSON5 reading support in the last version, but we can't make use of JSON5 syntax when generating JSON string. It would be very useful when generating config file with less verbose JSON5 syntax.
Describe the solution you'd like
Add write flag YYJSON_WRITE_MINIMAL_JSON5, which
- use unquoted keys if possible (start with an alpha char, doesn't contain white space or escaped codes, etc)
- use single quoted strings when meaningful. If the string contains
"but not', use single quoted string. Use double quoted string otherwise. (Should we add a flag that prefer'over"?) - use named escape codes if possible.
YYJSON_WRITE_ESCAPE_UNICODEwith additional escape codes introduced in JSON5 (\0,\e, etc). Prefer\xXXover\u00XX.
Describe alternatives you've considered N/A
Additional context N/A