type RawValue … // Clone returns a copy of v. func (v RawValue) Clone() RawValue { … } // String returns the string formatting of v. func (v RawValue) String() string { … } // IsValid reports whether the raw JSON value is syntactically valid // according to RFC 7493. // // It verifies whether the input is properly encoded as UTF-8, // that escape sequences within strings decode to valid Unicode codepoints, and // that all names in each object are unique. // It does not verify whether numbers are representable within the limits // of any common numeric type (e.g., float64, int64, or uint64). func (v RawValue) IsValid() bool { … } // Compact removes all whitespace from the raw JSON value. // // It does not reformat JSON strings to use any other representation. // It is guaranteed to succeed if the input is valid. // If the value is already compacted, then the buffer is not mutated. func (v *RawValue) Compact() error { … } // Indent reformats the whitespace in the raw JSON value so that each element // in a JSON object or array begins on a new, indented line beginning with // prefix followed by one or more copies of indent according to the nesting. // The value does not begin with the prefix nor any indention, // to make it easier to embed inside other formatted JSON data. // // It does not reformat JSON strings to use any other representation. // It is guaranteed to succeed if the input is valid. // If the value is already indented properly, then the buffer is not mutated. func (v *RawValue) Indent(prefix, indent string) error { … } // Canonicalize canonicalizes the raw JSON value according to the // JSON Canonicalization Scheme (JCS) as defined by RFC 8785 // where it produces a stable representation of a JSON value. // // The output stability is dependent on the stability of the application data // (see RFC 8785, Appendix E). It cannot produce stable output from // fundamentally unstable input. For example, if the JSON value // contains ephemeral data (e.g., a frequently changing timestamp), // then the value is still unstable regardless of whether this is called. // // Note that JCS treats all JSON numbers as IEEE 754 double precision numbers. // Any numbers with precision beyond what is representable by that form // will lose their precision when canonicalized. For example, integer values // beyond ±2⁵³ will lose their precision. It is recommended that // int64 and uint64 data types be represented as a JSON string. // // It is guaranteed to succeed if the input is valid. // If the value is already canonicalized, then the buffer is not mutated. func (v *RawValue) Canonicalize() error { … } // MarshalJSON returns v as the JSON encoding of v. // It returns the stored value as the raw JSON output without any validation. // If v is nil, then this returns a JSON null. func (v RawValue) MarshalJSON() ([]byte, error) { … } // UnmarshalJSON sets v as the JSON encoding of b. // It stores a copy of the provided raw JSON input without any validation. func (v *RawValue) UnmarshalJSON(b []byte) error { … } // Kind returns the starting token kind. // For a valid value, this will never include '}' or ']'. func (v RawValue) Kind() Kind { … } func (v *RawValue) reformat(canonical, multiline bool, prefix, indent string) error { … } func trimLeftSpaceTab(s string) string { … } type memberName … var memberNamePool … func getMemberNames() *memberNames { … } func putMemberNames(ns *memberNames) { … } type memberNames … func (m *memberNames) Len() int { … } func (m *memberNames) Less(i, j int) bool { … } func (m *memberNames) Swap(i, j int) { … } // reorderObjects recursively reorders all object members in place // according to the ordering specified in RFC 8785, section 3.2.3. // // Pre-conditions: // - The value is valid (i.e., no decoder errors should ever occur). // - The value is compact (i.e., no whitespace is present). // - Initial call is provided a Decoder reading from the start of v. // // Post-conditions: // - Exactly one JSON value is read from the Decoder. // - All fully-parsed JSON objects are reordered by directly moving // the members in the value buffer. // // The runtime is approximately O(n·log(n)) + O(m·log(m)), // where n is len(v) and m is the total number of object members. func reorderObjects(d *Decoder, scratch *[]byte) { … } // lessUTF16 reports whether x is lexicographically less than y according // to the UTF-16 codepoints of the UTF-8 encoded input strings. // This implements the ordering specified in RFC 8785, section 3.2.3. // The inputs must be valid UTF-8, otherwise this may panic. func lessUTF16[Bytes []byte | string](x, y Bytes) bool { … }