Documentation ¶
Index ¶
- Variables
- func EncodeAndWriteString[S ~string](w Writer, s S)
- func EncodeAndWriteStringWithoutHTMLEscape(w Writer, s []byte)
- func EncodeString[S ~string](s S) []byte
- func IsArray(d []byte) bool
- func IsBool(d []byte) bool
- func IsEmptyArray(d []byte) bool
- func IsEmptyObject(d []byte) bool
- func IsFalse(d []byte) bool
- func IsNull(d []byte) bool
- func IsNumber(data []byte) bool
- func IsObject(d []byte) bool
- func IsString(d []byte) bool
- func IsTrue(d []byte) bool
- func Marshal(v interface{}) ([]byte, error)
- func NewDecoder(r io.Reader) *json.Decoder
- func NewEncoder(w io.Writer) *json.Encoder
- func Unmarshal(data []byte, v any) error
- type Number
- func (n Number) BigFloat(m big.RoundingMode) (*big.Float, error)
- func (n Number) BigInt() (*big.Int, bool)
- func (n Number) BigRat() (*big.Rat, bool)
- func (n Number) Float64() (float64, error)
- func (n Number) Int64() (int64, error)
- func (n Number) MarshalJSON() ([]byte, error)
- func (n Number) String() string
- func (n *Number) UnmarshalJSON(data []byte) error
- type Object
- type RawMessage
- func (d RawMessage) ContainsEscapeRune() bool
- func (d RawMessage) Equal(data []byte) bool
- func (d RawMessage) IsArray() bool
- func (d RawMessage) IsBool() bool
- func (d RawMessage) IsEmptyArray() bool
- func (d RawMessage) IsEmptyObject() bool
- func (d RawMessage) IsFalse() bool
- func (d RawMessage) IsNull() bool
- func (d RawMessage) IsNumber() bool
- func (d RawMessage) IsObject() bool
- func (d RawMessage) IsString() bool
- func (d RawMessage) IsTrue() bool
- func (d RawMessage) Len() int
- func (d RawMessage) MarshalJSON() ([]byte, error)
- func (d *RawMessage) UnmarshalJSON(data []byte) error
- type Type
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( Null = RawMessage("null") True = RawMessage("true") False = RawMessage("false") )
Functions ¶
func EncodeAndWriteString ¶ added in v0.0.4
EncodeAndWriteString encodes a string to a json string literal, escaping any characters that are not permitted. It then writes the result to w.
Logic taken from encoding/json
func EncodeAndWriteStringWithoutHTMLEscape ¶ added in v0.0.6
func EncodeString ¶ added in v0.0.3
EncodeString encodes a string to a json string literal, escaping any characters that are not permitted.
EncodeString calls EncodeAndWriteString with a bytes.Buffer and returns the result.
Logic taken from encoding/json
func IsEmptyArray ¶
func IsEmptyObject ¶
func IsFalse ¶
IsFalse reports true if data appears to be a json boolean value of false. It is possible that it will report false positives of malformed json as it only checks the first character and length.
IsFalse does not parse strings
Types ¶
type Number ¶
A Number represents a JSON / YAML number literal.
func (Number) MarshalJSON ¶ added in v0.0.2
MarshalJSON marshals json
func (*Number) UnmarshalJSON ¶ added in v0.0.2
UnmarshalJSON unmarshals json
type Object ¶
type Object map[string]RawMessage
func (Object) MarshalJSON ¶
func (*Object) UnmarshalJSON ¶
type RawMessage ¶
type RawMessage []byte
func (RawMessage) ContainsEscapeRune ¶
func (d RawMessage) ContainsEscapeRune() bool
ContainsEscapeRune reports whether the string value of d contains "\" It returns false if d is not a quoted string.
func (RawMessage) Equal ¶
func (d RawMessage) Equal(data []byte) bool
func (RawMessage) IsArray ¶
func (d RawMessage) IsArray() bool
IsArray reports whether the data is a json array. It does not check whether the json is malformed.
func (RawMessage) IsBool ¶
func (d RawMessage) IsBool() bool
IsBool reports true if data appears to be a json boolean value. It is possible that it will report false positives of malformed json.
IsBool does not parse strings
func (RawMessage) IsEmptyArray ¶
func (d RawMessage) IsEmptyArray() bool
func (RawMessage) IsEmptyObject ¶
func (d RawMessage) IsEmptyObject() bool
func (RawMessage) IsFalse ¶
func (d RawMessage) IsFalse() bool
IsFalse reports true if data appears to be a json boolean value of false. It is possible that it will report false positives of malformed json as it only checks the first character and length.
IsFalse does not parse strings
func (RawMessage) IsNull ¶
func (d RawMessage) IsNull() bool
func (RawMessage) IsNumber ¶
func (d RawMessage) IsNumber() bool
func (RawMessage) IsObject ¶
func (d RawMessage) IsObject() bool
func (RawMessage) IsString ¶
func (d RawMessage) IsString() bool
func (RawMessage) IsTrue ¶
func (d RawMessage) IsTrue() bool
IsTrue reports true if data appears to be a json boolean value of true. It is possible that it will report false positives of malformed json as it only checks the first character and length.
IsTrue does not parse strings
func (RawMessage) Len ¶
func (d RawMessage) Len() int
func (RawMessage) MarshalJSON ¶
func (d RawMessage) MarshalJSON() ([]byte, error)
func (*RawMessage) UnmarshalJSON ¶
func (d *RawMessage) UnmarshalJSON(data []byte) error