package simplejson
import "github.com/bitly/go-simplejson"
Index ¶
- func Version() string
- type Json
- func NewJson(body []byte) (*Json, error)
- func (j *Json) Array() ([]interface{}, error)
- func (j *Json) Bool() (bool, error)
- func (j *Json) Bytes() ([]byte, error)
- func (j *Json) CheckGet(key string) (*Json, bool)
- func (j *Json) Encode() ([]byte, error)
- func (j *Json) Float64() (float64, error)
- func (j *Json) Get(key string) *Json
- func (j *Json) GetIndex(index int) *Json
- func (j *Json) Int() (int, error)
- func (j *Json) Int64() (int64, error)
- func (j *Json) Map() (map[string]interface{}, error)
- func (j *Json) MarshalJSON() ([]byte, error)
- func (j *Json) MustFloat64(args ...float64) float64
- func (j *Json) MustInt(args ...int) int
- func (j *Json) MustString(args ...string) string
- func (j *Json) String() (string, error)
- func (j *Json) UnmarshalJSON(p []byte) error
Functions ¶
func Version ¶
func Version() string
returns the current implementation version
Types ¶
type Json ¶
type Json struct {
// contains filtered or unexported fields
}
func NewJson ¶
NewJson returns a pointer to a new `Json` object after unmarshaling `body` bytes
func (*Json) Array ¶
Array type asserts to an `array`
func (*Json) Bool ¶
Bool type asserts to `bool`
func (*Json) Bytes ¶
Bytes type asserts to `[]byte`
func (*Json) CheckGet ¶
CheckGet returns a pointer to a new `Json` object and a `bool` identifying success or failure
useful for chained operations when success is important:
if data, ok := js.Get("top_level").CheckGet("inner"); ok { log.Println(data) }
func (*Json) Encode ¶
Encode returns its marshaled data as `[]byte`
func (*Json) Float64 ¶
Float64 type asserts to `float64`
func (*Json) Get ¶
Get returns a pointer to a new `Json` object for `key` in its `map` representation
useful for chaining operations (to traverse a nested JSON):
js.Get("top_level").Get("dict").Get("value").Int()
func (*Json) GetIndex ¶
GetIndex resturns a pointer to a new `Json` 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 (*Json) Int ¶
Int type asserts to `float64` then converts to `int`
func (*Json) Int64 ¶
Int type asserts to `float64` then converts to `int64`
func (*Json) Map ¶
Map type asserts to `map`
func (*Json) MarshalJSON ¶
Implements the json.Marshaler interface.
func (*Json) MustFloat64 ¶
MustFloat64 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").MustFloat64(), js.Get("optional_param").MustFloat64(5.150))
func (*Json) MustInt ¶
MustInt 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").MustInt(), js.Get("optional_param").MustInt(5150))
func (*Json) MustString ¶
MustString 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").MustString(), js.Get("optional_param").MustString("my_default"))
func (*Json) String ¶
String type asserts to `string`
func (*Json) UnmarshalJSON ¶
Implements the json.Unmarshaler interface.
Source Files ¶
- Version
- v0.4.1
- Published
- Oct 31, 2012
- Platform
- js/wasm
- Imports
- 3 packages
- Last checked
- now –
Tools for package owners.