DAW JSON Link
|
Many of the member types have options that can change how they are parsed. The options and their setters are located in the daw::json::options
namespace and are placed into Options
template parameter via a setter function that encodes the options into a json_options_t
.
To set number options use the daw::json::options::number_opt( Flags... )
method.
Controls the ability to parse numbers that are encoded as strings.
Never
- Never allow parsing this member as a string. It is a parser error if this member is encoded as a stringMaybe
- Allow parsing this member as a string or number.Always
- Only allow parsing this member as a string. It is an error for this member to not be encoded as a string.Never
- Do not attempt to check for narrowing when parsing integral typesCheckForNarrowing
- Attempt to check for narrowing when parsing integral typesNever
When outputting floating point numbers, control whether Inf/NaN values can be parsed/serialized. This requires that the LiteralAsString
option be set to Maybe
or Always
None
- Do not allow serialization/parsing of NaN/InfAllowNaN
- Allow NaN to be expressed/parsed if number can be a stringAllowInf
- Allow Inf/-Inf to be expressed/parsed if number can be a stringAllowNanInf
- Allow NaN/Inf/-Inf to be expressed/parsed if number can be a stringNone
Control the floating point output format
Auto
- Automatically choose between decimal and scientific output formats.Scientific
- Always format in terms of an exponent <whole>[.fraction]e<exponent>
.Decimal
- Always format in terms of an exponent <whole>[.fraction]e<exponent>
.Auto
To set bool options use the daw::json::options::bool_opt( Flags... )
method.
Controls the ability to parse booleans that are encoded as strings.
Never
- Never allow parsing this member as a string. It is a parser error if this member is encoded as a stringMaybe
- Allow parsing this member as a string or number.Always
- Only allow parsing this member as a string. It is an error for this member to not be encoded as a string.Never
To set string options use the daw::json::options::string_opt( Flags... )
method.
Controls whether any string character has the high bit set. If restricted, the member will escape any character with the high bit set and when parsing will throw if the high bit is encountered. This allows 7bit JSON encoding.
DisallowHigh
- Escape any character with the high bit set and throw when encountered during parseAllowFull
- Allow the full 8bits in output without escapingAllowFull
To set raw string options use the daw::json::options::string_raw_opt( Flags... )
method.
Controls whether any string character has the high bit set. If restricted, the member will escape any character with the high bit set and when parsing will throw if the high bit is encountered. This allows 7bit JSON encoding.
DisallowHigh
- Escape any character with the high bit set and throw when encountered during parseAllowFull
- Allow the full 8bits in output without escapingAllowFull
In RAW String processing, if we know that there are no escaped double quotes \"
we can stop at the first double quote. This allows faster string parsing
Allow
- Full string processing to skip escaped charactersNoEscapedDblQuote
- There will never be a " sequence inside the string. This allows faster parsingAllow
To set json_custom options use the daw::json::options::json_custom_opt( Flags... )
method.
Custom JSON types can be Strings(default), unquoted Literals, or a mix.
String
- Parser always expects a JSON string. Will surround serialized value with double quotesLiteral
- Parser will expect a valid JSON literal number, bool, nullAny
(Experimental) Parser will return any valid JSON value excluding leading whitespace. strings will be quoted. Any
is suitable for constructing a json_value
to allow adhoc parsing if json_raw
is not suitable