Documentation
¶
Overview ¶
Package options is the state of the options of jsontext and of the v2 json package: both packages take the same Options, so that the options of one may be given to the functions of the other, as encoding/json/v2 and encoding/json/jsontext allow. An Options can't be made outside this module: its method takes a type of this internal package.
Index ¶
Constants ¶
const DefaultV1Flags = AllowDuplicateNames | AllowInvalidUTF8 | EscapeForHTML | EscapeForJS | PreserveRawStrings | Deterministic | FormatNilMapAsNull | FormatNilSliceAsNull | MatchCaseInsensitiveNames | V1OptionFlags
DefaultV1Flags are the properties which DefaultOptionsV1 of the root package sets to true, and DefaultOptionsV2 of the v2 json package to false: the ones whose defaults differ between encoding/json and encoding/json/v2.
const V1OptionFlags = maxV1OptionFlag - ParseBytesWithLooseRFC4648
V1OptionFlags are the properties of the semantics of encoding/json: the flags from ParseBytesWithLooseRFC4648 to the last one, which the flag after it less the first one sets.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool uint8
Bool is the option of a property which is true or false: the index of the bit of its flag shifted by one bit, with the value as the lowest bit. It is a byte, which an Options holds without an allocation, as the runtime has the values of the bytes: an option made for each call, as encoding/json/v2's are, costs nothing more.
type Config ¶
type Config struct {
Set Flags // the properties which an option set
Value Flags // the values of the properties which were set; the others are false
// the properties which are not booleans, valid when their bits are in Set
Indent string
Prefix string
Marshalers any // the *Marshalers of the v2 json package
Unmarshalers any // the *Unmarshalers of the v2 json package
}
Config is the state of the options: the properties which were set, and their values.
func (*Config) Apply ¶
Apply sets the options in order: an option set later overrides a property set by an earlier one. A Bool, as most options are, is applied without a call of its method.
type Flags ¶
type Flags uint64
Flags are properties which are true or false, and, for the properties whose values are not booleans, the bits which show that they are set.
const ( AllowDuplicateNames Flags = 1 << iota AllowInvalidUTF8 EscapeForHTML EscapeForJS PreserveRawStrings CanonicalizeRawInts CanonicalizeRawFloats ReorderRawObjects SpaceAfterColon SpaceAfterComma Multiline IndentSet // WithIndent was given: Config.Indent PrefixSet // WithIndentPrefix was given: Config.Prefix // OmitTopLevelNewline is set by the functions and methods which format a single value, whose output has no // line feed after the value, as an Encoder writes. OmitTopLevelNewline )
The properties of the encoders and the decoders of jsontext.
const ( StringifyNumbers Flags = maxCoderFlag << iota Deterministic FormatNilMapAsNull FormatNilSliceAsNull MatchCaseInsensitiveNames OmitZeroStructFields RejectUnknownMembers MarshalersSet // WithMarshalers was given: Config.Marshalers UnmarshalersSet // WithUnmarshalers was given: Config.Unmarshalers // StringTag is set by no option: the encoder which a method or a function of a value of a field of the `string` // option is given has it, by which MarshalEncode of the encoder encodes the value as such a value, as // encoding/json/v2 has it, until an object or an array begins. StringTag // UnmarshalAnyWithRawNumber is set by no option: the decoder which a Decoder of the root package gives // UnmarshalJSONFrom after UseNumber has it, by which UnmarshalDecode of the decoder decodes a number into an empty // interface as a json.Number, as encoding/json/v2 has it for encoding/json. UnmarshalAnyWithRawNumber )
The properties of marshaling and unmarshaling Go values, of the v2 json package.
const ( ParseBytesWithLooseRFC4648 Flags = maxArshalFlag << iota ParseTimeWithLooseRFC3339 UnmarshalArrayFromAnyLength MergeWithLegacySemantics MatchCaseSensitiveDelimiter CallMethodsWithLegacySemantics FormatByteArrayAsArray FormatBytesWithLegacySemantics FormatDurationAsNano ReportErrorsWithLegacySemantics StringifyWithLegacySemantics OmitEmptyWithLegacySemantics )
The properties of marshaling and unmarshaling Go values by the semantics of encoding/json ( v1 ), which the options of the root package set, as the ones of encoding/json do: the v2 json package applies each of them, alone or with the others.