jsonx

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 5 Imported by: 1

README

jay

A simple package that wraps JSON in []byte form to provide methods on detecting the content as well as Marshaling/Unmarshaling.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Null  = RawMessage("null")
	True  = RawMessage("true")
	False = RawMessage("false")
)

Functions

func IsArray

func IsArray(d []byte) bool

func IsBool

func IsBool(d []byte) bool

func IsEmptyArray

func IsEmptyArray(d []byte) bool

func IsEmptyObject

func IsEmptyObject(d []byte) bool

func IsFalse

func IsFalse(d []byte) 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 IsNull

func IsNull(d []byte) bool

func IsNumber

func IsNumber(data []byte) bool

IsValid reports whether s is a valid JSON number literal.

Taken from encoding/json/scanner.go

func IsObject

func IsObject(d []byte) bool

func IsString

func IsString(d []byte) bool

func IsTrue

func IsTrue(d []byte) 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 Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal calls json.Marshal

func NewDecoder

func NewDecoder(r io.Reader) *json.Decoder

NewDecoder calls json.NewDecoder

func NewEncoder

func NewEncoder(w io.Writer) *json.Encoder

NewEncoder calls json.NewEncoder

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal calls json.Unmarshal

Types

type Number

type Number = json.Number

type Object

type Object map[string]RawMessage

func (Object) MarshalJSON

func (obj Object) MarshalJSON() ([]byte, error)

func (*Object) UnmarshalJSON

func (obj *Object) UnmarshalJSON(data []byte) error

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

type Type

type Type uint8
const (
	TypeInvalid Type = iota
	TypeEmpty
	TypeNull
	TypeBool
	TypeNumber
	TypeString
	TypeArray
	TypeObject
)

func TypeOf

func TypeOf(d []byte) Type

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL