Documentation
¶
Index ¶
- func DecodeWTF8Surrogate(value string) (uint16, bool)
- func Marshal(value any) ([]byte, error)
- func MarshalIndent(value any, prefix, indent string) ([]byte, error)
- func MarshalString(value string) ([]byte, error)
- func MessageRoleAndText(raw json.RawMessage) (string, string)
- func UnmarshalString(data []byte) (string, error)
- func UnmarshalStringToken(data []byte) (string, error)
- type OrderedMember
- type OrderedObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeWTF8Surrogate ¶
DecodeWTF8Surrogate returns the leading UTF-16 surrogate encoded as WTF-8.
func Marshal ¶
Marshal follows JSON.stringify's string escaping rather than encoding/json's HTML-safe defaults. JavaScript leaves <, >, &, U+2028, and U+2029 literal.
func MarshalIndent ¶
MarshalIndent matches JSON.stringify(value, null, 2)-style layout when called with ("", " "): Marshal's escaping plus json.Indent, which inserts whitespace without re-escaping.
func MarshalString ¶
MarshalString preserves WTF-8 encoded UTF-16 surrogates so Go can carry JavaScript strings produced by code-unit slicing through a JSON wire format.
func MessageRoleAndText ¶
func MessageRoleAndText(raw json.RawMessage) (string, string)
MessageRoleAndText preserves upstream's concatenation of text blocks with no separator.
func UnmarshalString ¶
UnmarshalString decodes a JSON string while retaining lone UTF-16 surrogates as WTF-8 so MarshalString can reproduce JSON.stringify output.
func UnmarshalStringToken ¶
UnmarshalStringToken decodes the first JSON string in a segment consumed by json.Decoder.Token. The segment may include separators and whitespace.
Types ¶
type OrderedMember ¶
OrderedMember is one name/value pair of an OrderedObject.
type OrderedObject ¶
type OrderedObject []OrderedMember
OrderedObject is a JSON object that marshals its members in insertion order, matching JavaScript's object key ordering on the wire.
func (*OrderedObject) Delete ¶
func (object *OrderedObject) Delete(name string)
Delete removes the first member with the given name, if present.
func (OrderedObject) MarshalJSON ¶
func (object OrderedObject) MarshalJSON() ([]byte, error)
func (*OrderedObject) Set ¶
func (object *OrderedObject) Set(name string, value any)
Set replaces the value of the first member with the given name in place, or appends a new member.