Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Key ¶
type Key string
Key represents a key for a member in a JSON object or an index for an element in a JSON array.
type Path ¶
type Path []Key
Path represents a sequence of the Keys. An empty path Path{} represents a root JSON value.
type Type ¶
type Type int
Type represents type of JSON values.
const ( // TypeNull represents the type for the JSON null value. TypeNull Type = iota // TypeString represents the type for the JSON string values. TypeString // TypeNumber represents the type for the JSON number values. TypeNumber // TypeBoolean represents the type for the JSON boolean values. TypeBoolean // TypeArray represents the type for the JSON array values. TypeArray // TypeObject represents the type for the JSON object values. TypeObject )
type Value ¶
type Value interface {
json.Marshaler
json.Unmarshaler
// Type returns JSON type.
Type() Type
// Assign assigns a JSON value to this object.
Assign(v Value)
// Clone deeply copies itself.
Clone() Value
// NumberGet returns this JSON value as a number.
NumberGet() json.Number
// StringGet returns this JSON value as a string.
StringGet() string
// BooleanGet returns this JSON value as a boolean.
BooleanGet() bool
// ObjectKeys returns keys of this JSON value as a object.
ObjectKeys() []string
// ObjectHasElm returns whether this JSON value as a object has the key.
ObjectHasElm(key string) bool
// ObjectHasElm returns a JSON value associated the key.
ObjectGetElm(key string) Value
// ObjectHasElm associates a JSON value by the key.
ObjectSetElm(key string, v Value)
// ObjectDelElm deletes the key and the associated JSON value.
ObjectDelElm(key string)
// ObjectLen returns the number of keys.
ObjectLen() int
// ArrayGetElm returns a JSON value indexed.
ArrayGetElm(index int) Value
// ArraySetElm sets a JSON value at the index.
ArraySetElm(index int, v Value)
// ArrayAddElm adds JSON values to the back.
ArrayAddElm(vs ...Value)
// ArrayLen returns the number of elements.
ArrayLen() int
// ArraySlice returns a sliced JSON array.
ArraySlice(begin int, endExclusive int) Value
}
Value models a JSON-structured data.
func Find ¶
Find finds the JSON value specified by the Path in a JSON value v. If the JSON value associated with the Path exists, the found JSON value and true are returned; otherwise nil and false are returned.
func Number ¶
func Number[V ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 | json.Number](n V) Value
Number returns a JSON number value of n.
Click to show internal directories.
Click to hide internal directories.