Documentation
¶
Overview ¶
Package jason helps deal with dynamic JSON.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Is ¶
Is checks if j can unmarshal into type T.
Example of testing if j can be converted into a time instant:
if jason.Is[time.Time](j) { ... }
Types ¶
type Array ¶
type Array[T any] []T
Array is a JSON array: an ordered collection of values.
Example of an Array literal:
jason.Array[int]{1, 2, 3}
type Number ¶
Number is an encoded JSON number.
It has arbitrary precision, and is easily converted to a float64 or int64.
Example of a Number literal:
jason.Number("10")
type Object ¶
Object is a JSON object: an unordered set of name/value pairs.
Example of an Object literal:
jason.Object[bool]{"abc": true}
type Value ¶
type Value []byte
Value is an encoded JSON value.
Like json.RawMessage, it implements json.Marshaler and json.Unmarshaler and can be used to delay/precompute JSON decoding/encoding.
Example of a Value literal:
jason.Value("false")
func From ¶
From marshals v into a Value, panics on error.
Example of creating a Value from a time instant:
jason.From(time.Now())
func (Value) MarshalJSON ¶
MarshalJSON returns j as the JSON encoding of j.
func (*Value) UnmarshalJSON ¶
UnmarshalJSON sets *j to a copy of data.