Documentation
¶
Index ¶
- Variables
- func RandToken(len int) string
- func ToJSON(data interface{}) (string, error)
- func ToJSONString(data interface{}) string
- type AtomicBool
- type Done
- type JSONArray
- type JSONBool
- type JSONData
- type JSONObject
- func (data JSONObject) GetAny(key string) (interface{}, bool)
- func (data JSONObject) GetArray(key string) (JSONArray, bool)
- func (data JSONObject) GetBool(key string) (bool, bool)
- func (data JSONObject) GetKeys() []string
- func (data JSONObject) GetNum(key string) *float64
- func (data JSONObject) GetNumber(key string) (float64, bool)
- func (data JSONObject) GetObj(key string) (JSONObject, bool)
- func (data JSONObject) GetString(key string) (string, bool)
- func (data JSONObject) HasKey(key string) bool
- func (data JSONObject) JSON() (string, error)
- func (data JSONObject) SetNumber(key string, val float64) bool
- func (data JSONObject) String() string
- func (data JSONObject) Type() string
Constants ¶
This section is empty.
Variables ¶
var TMP string
Functions ¶
func ToJSONString ¶
func ToJSONString(data interface{}) string
ToJSONString encodes any data into a JSON string if it fails it returns null
Types ¶
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
AtomicBool implements a thread safe boolean
func (*AtomicBool) Swap ¶
func (b *AtomicBool) Swap(val bool) bool
Swap sets a new value and returns the old value
type Done ¶
type Done struct {
// contains filtered or unexported fields
}
Done can be used to broadcast safely a done message across multiple goroutines
type JSONArray ¶
type JSONArray []interface{}
JSONArray provides convenience methods for arrays returned by the go JSON parser
type JSONBool ¶
type JSONBool bool
JSONBool provides json convenience methods for booleans
type JSONObject ¶
type JSONObject map[string]interface{}
JSONObject provides convenience methods for maps returned by the go JSON parser
func ParseJSON ¶
func ParseJSON(jsonStr []byte) (JSONObject, error)
ParseJSON parses a JSON string and returns a JSONObject
func (JSONObject) GetAny ¶
func (data JSONObject) GetAny(key string) (interface{}, bool)
GetAny returns any value from the JSON object
func (JSONObject) GetArray ¶
func (data JSONObject) GetArray(key string) (JSONArray, bool)
GetArray returns a value from the JSON object as JsonData
func (JSONObject) GetBool ¶
func (data JSONObject) GetBool(key string) (bool, bool)
GetBool returns a value from the JSON object as a boolean
func (JSONObject) GetKeys ¶
func (data JSONObject) GetKeys() []string
GetKeys returns an array of all the keys in this JSON object
func (JSONObject) GetNum ¶
func (data JSONObject) GetNum(key string) *float64
GetNum returns a value from the JSON object as a float64 or nil if not present or not a number
func (JSONObject) GetNumber ¶
func (data JSONObject) GetNumber(key string) (float64, bool)
GetNumber returns a value from the JSON object as a float64
func (JSONObject) GetObj ¶
func (data JSONObject) GetObj(key string) (JSONObject, bool)
GetObj returns a value from the JSON object as JsonData
func (JSONObject) GetString ¶
func (data JSONObject) GetString(key string) (string, bool)
GetString returns a value from the JSON object as string
func (JSONObject) HasKey ¶
func (data JSONObject) HasKey(key string) bool
HasKey returns true if the key is present
func (JSONObject) JSON ¶
func (data JSONObject) JSON() (string, error)
JSON encodes this JSONData object into a JSON string
func (JSONObject) SetNumber ¶
func (data JSONObject) SetNumber(key string, val float64) bool
SetNumber sets a float64 number on the object if it is not NaN
func (JSONObject) String ¶
func (data JSONObject) String() string
String encodes this JSONData object into a JSON string Like JSON but returns "{}" if it fails
func (JSONObject) Type ¶
func (data JSONObject) Type() string
Type returns the type of this JSONData entity