Documentation
¶
Index ¶
- Variables
- func Version() string
- type AnyValue
- func New() *AnyValue
- func NewFromInf(data interface{}) *AnyValue
- func NewFromJson(body []byte) (*AnyValue, error)
- func NewFromJsonReader(r io.Reader) (*AnyValue, error)
- func NewFromMsgPack(body []byte) (*AnyValue, error)
- func NewFromMsgPackReader(r io.Reader) (*AnyValue, error)
- func NewFromYaml(body []byte) (*AnyValue, error)
- func NewFromYamlReader(r io.Reader) (*AnyValue, error)
- func (j *AnyValue) Array() ([]interface{}, error)
- func (j *AnyValue) AsArray(args ...[]interface{}) []interface{}
- func (j *AnyValue) AsBool(args ...bool) bool
- func (j *AnyValue) AsFloat64(args ...float64) float64
- func (j *AnyValue) AsFloat64Arr(args ...[]float64) []float64
- func (j *AnyValue) AsInt(args ...int) int
- func (j *AnyValue) AsInt64(args ...int64) int64
- func (j *AnyValue) AsInt64Arr(args ...[]int64) []int64
- func (j *AnyValue) AsMap(args ...map[string]interface{}) map[string]interface{}
- func (j *AnyValue) AsStr(args ...string) string
- func (j *AnyValue) AsStrArr(args ...[]string) []string
- func (j *AnyValue) AsUInt64Arr(args ...[]uint64) []uint64
- func (j *AnyValue) AsUint64(args ...uint64) uint64
- func (j *AnyValue) Bool() (bool, error)
- func (j *AnyValue) Bytes() ([]byte, error)
- func (j *AnyValue) Del(key string)
- func (j *AnyValue) EncodeJson() ([]byte, error)
- func (j *AnyValue) EncodeJsonPretty() ([]byte, error)
- func (j *AnyValue) EncodeMsgPack() ([]byte, error)
- func (j *AnyValue) EncodeYaml() ([]byte, error)
- func (j *AnyValue) Exist(path string) (*AnyValue, bool)
- func (j *AnyValue) Float64() (float64, error)
- func (j *AnyValue) Float64Arr() ([]float64, error)
- func (j *AnyValue) Get(path string) *AnyValue
- func (j *AnyValue) GetIndex(index int) *AnyValue
- func (j *AnyValue) GetPath(branch ...string) *AnyValue
- func (j *AnyValue) Has(path string) bool
- func (j *AnyValue) Int() (int, error)
- func (j *AnyValue) Int64() (int64, error)
- func (j *AnyValue) Int64Arr() ([]int64, error)
- func (j *AnyValue) Interface() interface{}
- func (j *AnyValue) IsArray() bool
- func (j *AnyValue) IsBool() bool
- func (j *AnyValue) IsMap() bool
- func (j *AnyValue) IsNumber() bool
- func (j *AnyValue) IsStr() bool
- func (j *AnyValue) Map() (map[string]interface{}, error)
- func (j *AnyValue) MarshalJSON() ([]byte, error)
- func (j *AnyValue) MarshalMsgPack() ([]byte, error)
- func (j *AnyValue) MarshalYAML() ([]byte, error)
- func (j *AnyValue) Set(path string, val interface{}) *AnyValue
- func (j *AnyValue) SetPath(branch []string, val interface{}) *AnyValue
- func (j *AnyValue) Str() (string, error)
- func (j *AnyValue) StrArr() ([]string, error)
- func (j *AnyValue) UInt64Arr() ([]uint64, error)
- func (j *AnyValue) Uint64() (uint64, error)
- func (j *AnyValue) UnmarshalJSON(p []byte) error
- func (j *AnyValue) UnmarshalMsgPack(p []byte) error
- func (j *AnyValue) UnmarshalYAML(p []byte) error
Constants ¶
This section is empty.
Variables ¶
var AVNil = &AnyValue{nil}
Functions ¶
Types ¶
type AnyValue ¶
type AnyValue struct {
// contains filtered or unexported fields
}
func NewFromInf ¶
func NewFromInf(data interface{}) *AnyValue
New returns a pointer to a new, empty `AnyValue` object
func NewFromJson ¶
NewFromJson returns a pointer to a new `AnyValue` object after unmarshaling `body` bytes
func NewFromJsonReader ¶
NewFromReader returns a *AnyValue by decoding from an io.Reader
func NewFromMsgPack ¶
NewFromMsgPack returns a pointer to a new `AnyValue` object after unmarshaling `body` bytes
func NewFromMsgPackReader ¶
NewFromReader returns a *AnyValue by decoding from an io.Reader
func NewFromYaml ¶
NewFromYaml returns a pointer to a new `AnyValue` object after unmarshaling `body` bytes
func NewFromYamlReader ¶
NewFromReader returns a *AnyValue by decoding from an io.Reader
func (*AnyValue) AsArray ¶
func (j *AnyValue) AsArray(args ...[]interface{}) []interface{}
AsArray guarantees the return of a `[]interface{}` (with optional default)
useful when you want to interate over array values in a succinct manner:
for i, v := range js.Get("results").AsArray() { fmt.Println(i, v) }
func (*AnyValue) AsBool ¶
AsBool guarantees the return of a `bool` (with optional default)
useful when you explicitly want a `bool` in a single value return context:
myFunc(js.Get("param1").AsBool(), js.Get("optional_param").AsBool(true))
func (*AnyValue) AsFloat64 ¶
AsFloat64 guarantees the return of a `float64` (with optional default)
useful when you explicitly want a `float64` in a single value return context:
myFunc(js.Get("param1").AsFloat64(), js.Get("optional_param").AsFloat64(5.150))
func (*AnyValue) AsFloat64Arr ¶
func (*AnyValue) AsInt ¶
AsInt guarantees the return of an `int` (with optional default)
useful when you explicitly want an `int` in a single value return context:
myFunc(js.Get("param1").AsInt(), js.Get("optional_param").AsInt(5150))
func (*AnyValue) AsInt64 ¶
AsInt64 guarantees the return of an `int64` (with optional default)
useful when you explicitly want an `int64` in a single value return context:
myFunc(js.Get("param1").AsInt64(), js.Get("optional_param").AsInt64(5150))
func (*AnyValue) AsInt64Arr ¶
func (*AnyValue) AsMap ¶
AsMap guarantees the return of a `map[string]interface{}` (with optional default)
useful when you want to interate over map values in a succinct manner:
for k, v := range js.Get("dictionary").AsMap() { fmt.Println(k, v) }
func (*AnyValue) AsStr ¶
AsStr guarantees the return of a `string` (with optional default)
useful when you explicitly want a `string` in a single value return context:
myFunc(js.Get("param1").AsStr(), js.Get("optional_param").AsStr("Asmy_ault"))
func (*AnyValue) AsStrArr ¶
AsStrArr guarantees the return of a `[]string` (with optional default)
useful when you want to interate over array values in a succinct manner:
for i, s := range js.Get("results").AsStrArr() { fmt.Println(i, s) }
func (*AnyValue) AsUInt64Arr ¶
func (*AnyValue) AsUint64 ¶
AsUInt64 guarantees the return of an `uint64` (with optional default)
useful when you explicitly want an `uint64` in a single value return context:
myFunc(js.Get("param1").AsUint64(), js.Get("optional_param").AsUint64(5150))
func (*AnyValue) EncodeJson ¶
Encode returns its marshaled data as `[]byte`
func (*AnyValue) EncodeJsonPretty ¶
EncodePretty returns its marshaled data as `[]byte` with indentation
func (*AnyValue) EncodeMsgPack ¶
Encode returns its marshaled data as `[]byte`
func (*AnyValue) EncodeYaml ¶
Encode returns its marshaled data as `[]byte`
func (*AnyValue) Exist ¶
CheckGet returns a pointer to a new `AnyValue` object and a `bool` identifying success or failure
useful for chained operations when success is important:
if data, ok := js.Get("top_level").Exist("inner"); ok { log.Println(data) }
func (*AnyValue) Float64Arr ¶
IntArr type asserts to an `array` of `int`
func (*AnyValue) Get ¶
GetValue searches for the item as specified by the branch without the need to deep dive using Get()'s.
js.GetValue("top_level.dict")
func (*AnyValue) GetIndex ¶
GetIndex returns a pointer to a new `AnyValue` object for `index` in its `array` representation
this is the analog to Get when accessing elements of a json array instead of a json object:
js.Get("top_level").Get("array").GetIndex(1).Get("key").Int()
func (*AnyValue) GetPath ¶
GetPath searches for the item as specified by the branch without the need to deep dive using Get()'s.
js.GetPath("top_level", "dict")
func (*AnyValue) Interface ¶
func (j *AnyValue) Interface() interface{}
Interface returns the underlying data
func (*AnyValue) MarshalJSON ¶
Implements the json.Marshaler interface.
func (*AnyValue) MarshalMsgPack ¶
Implements the msgpack.Marshaler interface.
func (*AnyValue) MarshalYAML ¶
Implements the yaml.Marshaler interface.
func (*AnyValue) SetPath ¶
SetPath modifies `AnyValue`, recursively checking/creating map keys for the supplied path, and then finally writing in the value
func (*AnyValue) UnmarshalJSON ¶
Implements the json.Unmarshaler interface.
func (*AnyValue) UnmarshalMsgPack ¶
Implements the json.Unmarshaler interface.
func (*AnyValue) UnmarshalYAML ¶
Implements the yaml.Unmarshaler interface.