Documentation ¶
Index ¶
- type JsonMap
- func (m *JsonMap) GetBool(key string) (bool, error)
- func (m *JsonMap) GetBoolAtPath(path string) (bool, error)
- func (m *JsonMap) GetBoolAtPathWithDefault(path string, defaultValue bool) (bool, error)
- func (m *JsonMap) GetBoolWithDefault(key string, defaultValue bool) (bool, error)
- func (m *JsonMap) GetFloat(key string) (float64, error)
- func (m *JsonMap) GetFloatAtPath(path string) (float64, error)
- func (m *JsonMap) GetFloatAtPathWithDefault(path string, defaultValue float64) (float64, error)
- func (m *JsonMap) GetFloatWithDefault(key string, defaultValue float64) (float64, error)
- func (m *JsonMap) GetInt(key string) (int64, error)
- func (m *JsonMap) GetIntAtPath(path string) (int64, error)
- func (m *JsonMap) GetIntAtPathWithDefault(path string, defaultValue int64) (int64, error)
- func (m *JsonMap) GetIntWithDefault(key string, defaultValue int64) (int64, error)
- func (m *JsonMap) GetMap(key string) (JsonMap, error)
- func (m *JsonMap) GetMapAtPath(path string) (JsonMap, error)
- func (m *JsonMap) GetMapAtPathWithDefault(path string, defaultValue JsonMap) (JsonMap, error)
- func (m *JsonMap) GetMapWithDefault(key string, defaultValue JsonMap) (JsonMap, error)
- func (m *JsonMap) GetSlice(key string) (JsonSlice, error)
- func (m *JsonMap) GetSliceAtPath(path string) (JsonSlice, error)
- func (m *JsonMap) GetSliceAtPathWithDefault(path string, defaultValue JsonSlice) (JsonSlice, error)
- func (m *JsonMap) GetSliceOfBools(key string) ([]bool, error)
- func (m *JsonMap) GetSliceOfBoolsAtPath(path string) ([]bool, error)
- func (m *JsonMap) GetSliceOfBoolsAtPathWithDefault(path string, defaultValue []bool) ([]bool, error)
- func (m *JsonMap) GetSliceOfBoolsWithDefault(key string, defaultValue []bool) ([]bool, error)
- func (m *JsonMap) GetSliceOfFloats(key string) ([]float64, error)
- func (m *JsonMap) GetSliceOfFloatsAtPath(path string) ([]float64, error)
- func (m *JsonMap) GetSliceOfFloatsAtPathWithDefault(path string, defaultValue []float64) ([]float64, error)
- func (m *JsonMap) GetSliceOfFloatsWithDefault(key string, defaultValue []float64) ([]float64, error)
- func (m *JsonMap) GetSliceOfInts(key string) ([]int64, error)
- func (m *JsonMap) GetSliceOfIntsAtPath(path string) ([]int64, error)
- func (m *JsonMap) GetSliceOfIntsAtPathWithDefault(path string, defaultValue []int64) ([]int64, error)
- func (m *JsonMap) GetSliceOfIntsWithDefault(key string, defaultValue []int64) ([]int64, error)
- func (m *JsonMap) GetSliceOfMaps(key string) ([]JsonMap, error)
- func (m *JsonMap) GetSliceOfMapsAtPath(path string) ([]JsonMap, error)
- func (m *JsonMap) GetSliceOfMapsAtPathWithDefault(path string, defaultValue []JsonMap) ([]JsonMap, error)
- func (m *JsonMap) GetSliceOfMapsWithDefault(key string, defaultValue []JsonMap) ([]JsonMap, error)
- func (m *JsonMap) GetSliceOfSlices(key string) ([]JsonSlice, error)
- func (m *JsonMap) GetSliceOfSlicesAtPath(path string) ([]JsonSlice, error)
- func (m *JsonMap) GetSliceOfSlicesAtPathWithDefault(path string, defaultValue []JsonSlice) ([]JsonSlice, error)
- func (m *JsonMap) GetSliceOfSlicesWithDefault(key string, defaultValue []JsonSlice) ([]JsonSlice, error)
- func (m *JsonMap) GetSliceOfStrings(key string) ([]string, error)
- func (m *JsonMap) GetSliceOfStringsAtPath(path string) ([]string, error)
- func (m *JsonMap) GetSliceOfStringsAtPathWithDefault(path string, defaultValue []string) ([]string, error)
- func (m *JsonMap) GetSliceOfStringsWithDefault(key string, defaultValue []string) ([]string, error)
- func (m *JsonMap) GetSliceWithDefault(key string, defaultValue JsonSlice) (JsonSlice, error)
- func (m *JsonMap) GetString(key string) (string, error)
- func (m *JsonMap) GetStringAtPath(path string) (string, error)
- func (m *JsonMap) GetStringAtPathWithDefault(path string, defaultValue string) (string, error)
- func (m *JsonMap) GetStringWithDefault(key string, defaultValue string) (string, error)
- func (m *JsonMap) GetValue(key string) (interface{}, error)
- func (m *JsonMap) GetValueAtPath(path string) (interface{}, error)
- func (m *JsonMap) GetValueAtPathWithDefault(path string, defaultValue interface{}) interface{}
- func (m *JsonMap) GetValueWithDefault(key string, defaultValue interface{}) interface{}
- func (m *JsonMap) Map(mapMapFn MapMapFn, sliceMapFn SliceMapFn) JsonMap
- func (m *JsonMap) SetBool(key string, value bool)
- func (m *JsonMap) SetBoolAtPath(path string, value bool) error
- func (m *JsonMap) SetFloat(key string, value float64)
- func (m *JsonMap) SetFloatAtPath(path string, value float64) error
- func (m *JsonMap) SetInt(key string, value int64)
- func (m *JsonMap) SetIntAtPath(path string, value int64) error
- func (m *JsonMap) SetMap(key string, value JsonMap)
- func (m *JsonMap) SetMapAtPath(path string, value JsonMap) error
- func (m *JsonMap) SetSlice(key string, value JsonSlice)
- func (m *JsonMap) SetSliceAtPath(path string, value JsonSlice) error
- func (m *JsonMap) SetString(key string, value string)
- func (m *JsonMap) SetStringAtPath(path string, value string) error
- func (m *JsonMap) SetValue(key string, value interface{})
- func (m *JsonMap) SetValueAtPath(path string, value interface{}) error
- func (m *JsonMap) ToIoWriter(jsonWriter io.Writer, pretty bool, escapeHtml bool) error
- func (m *JsonMap) ToJsonBytes(pretty bool, escapeHtml bool) ([]byte, error)
- func (m *JsonMap) ToJsonString(pretty bool, escapeHtml bool) (string, error)
- type JsonSlice
- func (s *JsonSlice) GetBool(index int) (bool, error)
- func (s *JsonSlice) GetBoolAtPath(path string) (bool, error)
- func (s *JsonSlice) GetBoolAtPathWithDefault(path string, defaultValue bool) (bool, error)
- func (s *JsonSlice) GetBoolWithDefault(index int, defaultValue bool) (bool, error)
- func (s *JsonSlice) GetFloat(index int) (float64, error)
- func (s *JsonSlice) GetFloatAtPath(path string) (float64, error)
- func (s *JsonSlice) GetFloatAtPathWithDefault(path string, defaultValue float64) (float64, error)
- func (s *JsonSlice) GetFloatWithDefault(index int, defaultValue float64) (float64, error)
- func (s *JsonSlice) GetInt(index int) (int64, error)
- func (s *JsonSlice) GetIntAtPath(path string) (int64, error)
- func (s *JsonSlice) GetIntAtPathWithDefault(path string, defaultValue int64) (int64, error)
- func (s *JsonSlice) GetIntWithDefault(index int, defaultValue int64) (int64, error)
- func (s *JsonSlice) GetMap(index int) (JsonMap, error)
- func (s *JsonSlice) GetMapAtPath(path string) (JsonMap, error)
- func (s *JsonSlice) GetMapAtPathWithDefault(path string, defaultValue JsonMap) (JsonMap, error)
- func (s *JsonSlice) GetMapWithDefault(index int, defaultValue JsonMap) (JsonMap, error)
- func (s *JsonSlice) GetSlice(index int) (JsonSlice, error)
- func (s *JsonSlice) GetSliceAtPath(path string) (JsonSlice, error)
- func (s *JsonSlice) GetSliceAtPathWithDefault(path string, defaultValue JsonSlice) (JsonSlice, error)
- func (s *JsonSlice) GetSliceOfBools(index int) ([]bool, error)
- func (s *JsonSlice) GetSliceOfBoolsAtPath(path string) ([]bool, error)
- func (s *JsonSlice) GetSliceOfBoolsAtPathWithDefault(path string, defaultValue []bool) ([]bool, error)
- func (s *JsonSlice) GetSliceOfBoolsWithDefault(index int, defaultValue []bool) ([]bool, error)
- func (s *JsonSlice) GetSliceOfFloats(index int) ([]float64, error)
- func (s *JsonSlice) GetSliceOfFloatsAtPath(path string) ([]float64, error)
- func (s *JsonSlice) GetSliceOfFloatsAtPathWithDefault(path string, defaultValue []float64) ([]float64, error)
- func (s *JsonSlice) GetSliceOfFloatsWithDefault(index int, defaultValue []float64) ([]float64, error)
- func (s *JsonSlice) GetSliceOfInts(index int) ([]int64, error)
- func (s *JsonSlice) GetSliceOfIntsAtPath(path string) ([]int64, error)
- func (s *JsonSlice) GetSliceOfIntsAtPathWithDefault(path string, defaultValue []int64) ([]int64, error)
- func (s *JsonSlice) GetSliceOfIntsWithDefault(index int, defaultValue []int64) ([]int64, error)
- func (s *JsonSlice) GetSliceOfMaps(index int) ([]JsonMap, error)
- func (s *JsonSlice) GetSliceOfMapsAtPath(path string) ([]JsonMap, error)
- func (s *JsonSlice) GetSliceOfMapsAtPathWithDefault(path string, defaultValue []JsonMap) ([]JsonMap, error)
- func (s *JsonSlice) GetSliceOfMapsWithDefault(index int, defaultValue []JsonMap) ([]JsonMap, error)
- func (s *JsonSlice) GetSliceOfSlices(index int) ([]JsonSlice, error)
- func (s *JsonSlice) GetSliceOfSlicesAtPath(path string) ([]JsonSlice, error)
- func (s *JsonSlice) GetSliceOfSlicesAtPathWithDefault(path string, defaultValue []JsonSlice) ([]JsonSlice, error)
- func (s *JsonSlice) GetSliceOfSlicesWithDefault(index int, defaultValue []JsonSlice) ([]JsonSlice, error)
- func (s *JsonSlice) GetSliceOfStrings(index int) ([]string, error)
- func (s *JsonSlice) GetSliceOfStringsAtPath(path string) ([]string, error)
- func (s *JsonSlice) GetSliceOfStringsAtPathWithDefault(path string, defaultValue []string) ([]string, error)
- func (s *JsonSlice) GetSliceOfStringsWithDefault(index int, defaultValue []string) ([]string, error)
- func (s *JsonSlice) GetSliceWithDefault(index int, defaultValue JsonSlice) (JsonSlice, error)
- func (s *JsonSlice) GetString(index int) (string, error)
- func (s *JsonSlice) GetStringAtPath(path string) (string, error)
- func (s *JsonSlice) GetStringAtPathWithDefault(path string, defaultValue string) (string, error)
- func (s *JsonSlice) GetStringWithDefault(index int, defaultValue string) (string, error)
- func (s *JsonSlice) GetValue(index int) (interface{}, error)
- func (s *JsonSlice) GetValueAtPath(path string) (interface{}, error)
- func (s *JsonSlice) GetValueAtPathWithDefault(path string, defaultValue interface{}) interface{}
- func (s *JsonSlice) GetValueWithDefault(index int, defaultValue interface{}) interface{}
- func (s *JsonSlice) Map(mapMapFn MapMapFn, sliceMapFn SliceMapFn) JsonSlice
- func (s *JsonSlice) SetBool(index int, value bool) error
- func (s *JsonSlice) SetBoolAtPath(path string, value bool) error
- func (s *JsonSlice) SetFloat(index int, value float64) error
- func (s *JsonSlice) SetFloatAtPath(path string, value float64) error
- func (s *JsonSlice) SetInt(index int, value int64) error
- func (s *JsonSlice) SetIntAtPath(path string, value int64) error
- func (s *JsonSlice) SetMap(index int, value JsonMap) error
- func (s *JsonSlice) SetMapAtPath(path string, value JsonMap) error
- func (s *JsonSlice) SetSlice(index int, value JsonSlice) error
- func (s *JsonSlice) SetSliceAtPath(path string, value JsonSlice) error
- func (s *JsonSlice) SetString(index int, value string) error
- func (s *JsonSlice) SetStringAtPath(path string, value string) error
- func (s *JsonSlice) SetValue(index int, value interface{}) error
- func (s *JsonSlice) SetValueAtPath(path string, value interface{}) error
- func (s *JsonSlice) ToIoWriter(jsonWriter io.Writer, pretty bool, escapeHtml bool) error
- func (s *JsonSlice) ToJsonBytes(pretty bool, escapeHtml bool) ([]byte, error)
- func (s *JsonSlice) ToJsonString(pretty bool, escapeHtml bool) (string, error)
- type MapMapFn
- type SliceMapFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JsonMap ¶
type JsonMap map[string]interface{}
func NewJsonMapFromIoReader ¶
NewJsonMapFromIoReader creates a JsonMap from an io.Reader. It returns an error if valid JSON cannot be decoded from the io.Reader. Note: This function expects the top-level JSON object to be a map and will fail if it is a slice (use NewJsonSliceFromIoReader for a top-level slice).
func NewJsonMapFromJsonBytes ¶
NewJsonMapFromJsonBytes creates a JsonMap from a byte slice. It returns an error if valid JSON cannot be decoded from the bytes. Note: This function expects the top-level JSON object to be a map and will fail if it is a slice (use NewJsonSliceFromJsonBytes for a top-level slice).
func NewJsonMapFromJsonString ¶
NewJsonMapFromJsonString creates a JsonMap from a string. It returns an error if valid JSON cannot be decoded from the string. Note: This function expects the top-level JSON object to be a map and will fail if it is a slice (use NewJsonSliceFromJsonString for a top-level slice).
func (*JsonMap) GetBool ¶
GetBool retrieves, from the map, a bool with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a bool.
func (*JsonMap) GetBoolAtPath ¶
GetBoolAtPath retrieves, from the map, a bool at the specified path. It will return an error if the path is invalid or if the value at the path is not a bool. Note that map paths should always begin with a key. e.g. "keyForMap.keyForBool" (map with a map with a bool value) or "keyForBoolSlice[0]" (map with a slice of bool values) or "keyForMap.keyForBoolSlice[0]" (map with a map with a slice of bool values)
func (*JsonMap) GetBoolAtPathWithDefault ¶
GetBoolAtPathWithDefault retrieves, from the map, a bool at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a bool. Note that map paths should always begin with a key. e.g. "keyForMap.keyForBool" (map with a map with a bool value) or "keyForBoolSlice[0]" (map with a slice of bool values) or "keyForMap.keyForBoolSlice[0]" (map with a map with a slice of bool values)
func (*JsonMap) GetBoolWithDefault ¶
GetBoolWithDefault retrieves, from the map, a bool with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a bool.
func (*JsonMap) GetFloat ¶
GetFloat retrieves, from the map, a float with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a float (if the value at the index is an integer, it will be quietly converted to a float).
func (*JsonMap) GetFloatAtPath ¶
GetFloatAtPath retrieves, from the map, a float at the specified path. It will return an error if the path is invalid or if the value at the path is not a float (if the value at the index is an int, it will be quietly converted to a float). Note that map paths should always begin with a key. e.g. "keyForMap.keyForFloat" (map with a map with a float value) or "keyForFloatSlice[0]" (map with a slice of float values) or "keyForMap.keyForFloatSlice[0]" (map with a map with a slice of float values)
func (*JsonMap) GetFloatAtPathWithDefault ¶
GetFloatAtPathWithDefault retrieves, from the map, a float at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a float (if the value at the index is an int, it will be quietly converted to a float). Note that map paths should always begin with a key. e.g. "keyForMap.keyForFloat" (map with a map with a float value) or "keyForFloatSlice[0]" (map with a slice of float values) or "keyForMap.keyForFloatSlice[0]" (map with a map with a slice of float values)
func (*JsonMap) GetFloatWithDefault ¶
GetFloatWithDefault retrieves, from the map, a float with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a float (if the value at the index is an integer, it will be quietly converted to a float).
func (*JsonMap) GetInt ¶
GetInt retrieves, from the map, an int with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not an int.
func (*JsonMap) GetIntAtPath ¶
GetIntAtPath retrieves, from the map, an int at the specified path. It will return an error if the path is invalid or if the value at the path is not an int. Note that map paths should always begin with a key. e.g. "keyForMap.keyForInt" (map with a map with an int value) or "keyForIntSlice[0]" (map with a slice of int values) or "keyForMap.keyForIntSlice[0]" (map with a map with a slice of int values)
func (*JsonMap) GetIntAtPathWithDefault ¶
GetIntAtPathWithDefault retrieves, from the map, an int at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not an int. Note that map paths should always begin with a key. e.g. "keyForMap.keyForInt" (map with a map with an int value) or "keyForIntSlice[0]" (map with a slice of int values) or "keyForMap.keyForIntSlice[0]" (map with a map with a slice of int values)
func (*JsonMap) GetIntWithDefault ¶
GetIntWithDefault retrieves, from the map, an int with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not an int.
func (*JsonMap) GetMap ¶
GetMap retrieves, from the map, a JsonMap with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonMap.
func (*JsonMap) GetMapAtPath ¶
GetMapAtPath retrieves, from the map, a JsonMap at the specified path. It will return an error if the path is invalid or if the value at the path is not a JsonMap. Note that map paths should always begin with a key. e.g. "keyForMap.keyForMap" (map with a map with a map value) or "keyForMapSlice[0]" (map with a slice of map values) or "keyForMap.keyForMapSlice[0]" (map with a map with a slice of map values)
func (*JsonMap) GetMapAtPathWithDefault ¶
GetMapAtPathWithDefault retrieves, from the map, a JsonMap at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonMap. Note that map paths should always begin with a key. e.g. "keyForMap.keyForMap" (map with a map with a map value) or "keyForMapSlice[0]" (map with a slice of map values) or "keyForMap.keyForMapSlice[0]" (map with a map with a slice of map values)
func (*JsonMap) GetMapWithDefault ¶
GetMapWithDefault retrieves, from the map, a JsonMap with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonMap.
func (*JsonMap) GetSlice ¶
GetSlice retrieves, from the map, a JsonSlice with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice.
func (*JsonMap) GetSliceAtPath ¶
GetSliceAtPath retrieves, from the map, a JsonSlice at the specified path. It will return an error if the path is invalid or if the value at the path is not a JsonSlice. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceAtPathWithDefault ¶
GetSliceAtPathWithDefault retrieves, from the map, a JsonSlice at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfBools ¶
GetSliceOfBools retrieves, from the map, a []bool64 with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not a bool.
func (*JsonMap) GetSliceOfBoolsAtPath ¶
GetSliceOfBoolsAtPath retrieves, from the map, a []bool at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a bool. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfBoolsAtPathWithDefault ¶
func (m *JsonMap) GetSliceOfBoolsAtPathWithDefault(path string, defaultValue []bool) ([]bool, error)
GetSliceOfBoolsAtPathWithDefault retrieves, from the map, a []bool at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a bool. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfBoolsWithDefault ¶
GetSliceOfBoolsWithDefault retrieves, from the map, a []bool64 with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not a bool.
func (*JsonMap) GetSliceOfFloats ¶
GetSliceOfFloats retrieves, from the map, a []float64 with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not a float.
func (*JsonMap) GetSliceOfFloatsAtPath ¶
GetSliceOfFloatsAtPath retrieves, from the map, a []float64 at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a float. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfFloatsAtPathWithDefault ¶
func (m *JsonMap) GetSliceOfFloatsAtPathWithDefault(path string, defaultValue []float64) ([]float64, error)
GetSliceOfFloatsAtPathWithDefault retrieves, from the map, a []float64 at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a float. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfFloatsWithDefault ¶
func (m *JsonMap) GetSliceOfFloatsWithDefault(key string, defaultValue []float64) ([]float64, error)
GetSliceOfFloatsWithDefault retrieves, from the map, a []float64 with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not a float.
func (*JsonMap) GetSliceOfInts ¶
GetSliceOfInts retrieves, from the map, a []int64 with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not an int.
func (*JsonMap) GetSliceOfIntsAtPath ¶
GetSliceOfIntsAtPath retrieves, from the map, a []int64 at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not an int. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfIntsAtPathWithDefault ¶
func (m *JsonMap) GetSliceOfIntsAtPathWithDefault(path string, defaultValue []int64) ([]int64, error)
GetSliceOfIntsAtPathWithDefault retrieves, from the map, a []int64 at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not an int. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfIntsWithDefault ¶
GetSliceOfIntsWithDefault retrieves, from the map, a []int64 with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not an int.
func (*JsonMap) GetSliceOfMaps ¶
GetSliceOfMaps retrieves, from the map, a []JsonMap with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not a JsonMap.
func (*JsonMap) GetSliceOfMapsAtPath ¶
GetSliceOfMapsAtPath retrieves, from the map, a []JsonMap at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a JsonMap. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfMapsAtPathWithDefault ¶
func (m *JsonMap) GetSliceOfMapsAtPathWithDefault(path string, defaultValue []JsonMap) ([]JsonMap, error)
GetSliceOfMapsAtPathWithDefault retrieves, from the map, a []JsonMap at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a JsonMap. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfMapsWithDefault ¶
GetSliceOfMapsWithDefault retrieves, from the map, a []JsonMap with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not a JsonMap.
func (*JsonMap) GetSliceOfSlices ¶
GetSliceOfSlices retrieves, from the map, a []JsonSlice with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not a JsonSlice.
func (*JsonMap) GetSliceOfSlicesAtPath ¶
GetSliceOfSlicesAtPath retrieves, from the map, a []JsonSlice at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a JsonSlice. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfSlicesAtPathWithDefault ¶
func (m *JsonMap) GetSliceOfSlicesAtPathWithDefault(path string, defaultValue []JsonSlice) ([]JsonSlice, error)
GetSliceOfSlicesAtPathWithDefault retrieves, from the map, a []JsonSlice at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a JsonSlice. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfSlicesWithDefault ¶
func (m *JsonMap) GetSliceOfSlicesWithDefault(key string, defaultValue []JsonSlice) ([]JsonSlice, error)
GetSliceOfSlicesWithDefault retrieves, from the map, a []JsonSlice with the specified key. If the key can not be found in the map (including an invalid, empty key, ""), then it returns the default value. It will return an error if the value at the index is not a JsonSlice or if any value in the slice is not a JsonSlice.
func (*JsonMap) GetSliceOfStrings ¶
GetSliceOfStrings retrieves, from the map, a []string with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not a string.
func (*JsonMap) GetSliceOfStringsAtPath ¶
GetSliceOfStringsAtPath retrieves, from the map, a []string at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a string. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfStringsAtPathWithDefault ¶
func (m *JsonMap) GetSliceOfStringsAtPathWithDefault(path string, defaultValue []string) ([]string, error)
GetSliceOfStringsAtPathWithDefault retrieves, from the map, a []string at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a string. Note that map paths should always begin with a key. e.g. "keyForMap.keyForSlice" (map with a map with a slice value) or "keyForSliceSlice[0]" (map with a slice of slice values) or "keyForMap.keyForSliceSlice[0]" (map with a map with a slice of slice values)
func (*JsonMap) GetSliceOfStringsWithDefault ¶
GetSliceOfStringsWithDefault retrieves, from the map, a []string with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice or if any value in the slice is not a string.
func (*JsonMap) GetSliceWithDefault ¶
GetSliceWithDefault retrieves, from the map, a JsonSlice with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a JsonSlice.
func (*JsonMap) GetString ¶
GetString retrieves, from the map, a string with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a string.
func (*JsonMap) GetStringAtPath ¶
GetStringAtPath retrieves, from the map, a string at the specified path. It will return an error if the path is invalid or if the value at the path is not a string. Note that map paths should always begin with a key. e.g. "keyForMap.keyForString" (map with a map with a string value) or "keyForStringSlice[0]" (map with a slice of string values) or "keyForMap.keyForStringSlice[0]" (map with a map with a slice of string values)
func (*JsonMap) GetStringAtPathWithDefault ¶
GetStringAtPathWithDefault retrieves, from the map, a string at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a string. Note that map paths should always begin with a key. e.g. "keyForMap.keyForString" (map with a map with a string value) or "keyForStringSlice[0]" (map with a slice of string values) or "keyForMap.keyForStringSlice[0]" (map with a map with a slice of string values)
func (*JsonMap) GetStringWithDefault ¶
GetStringWithDefault retrieves, from the map, a string with the specified key. It will return an error if the key does not exist in the map or if the value at the index is not a string.
func (*JsonMap) GetValue ¶
GetValue retrieves, from the map, an object of any type with the specified key. It will return an error if the key does not exist in the map.
func (*JsonMap) GetValueAtPath ¶
GetValueAtPath retrieves, from the map, an object of any type at the specified path. It will return an error if the path is invalid. Note that map paths should always begin with a key. e.g. "keyForMap.keyForValue" (map with a map with a value) or "keyForValueSlice[0]" (map with a slice of values) or "keyForMap.keyForValueSlice[0]" (map with a map with a slice of values)
func (*JsonMap) GetValueAtPathWithDefault ¶
GetValueAtPathWithDefault retrieves, from the map, an object of any type at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. Note that map paths should always begin with a key. e.g. "keyForMap.keyForValue" (map with a map with a value) or "keyForValueSlice[0]" (map with a slice of values) or "keyForMap.keyForValueSlice[0]" (map with a map with a slice of values)
func (*JsonMap) GetValueWithDefault ¶
GetValueWithDefault retrieves, from the map, an object of any type with the specified key. If the key can not be found in the map (including an invalid, empty key, ""), then it returns the default value.
func (*JsonMap) Map ¶
func (m *JsonMap) Map(mapMapFn MapMapFn, sliceMapFn SliceMapFn) JsonMap
Map recursively applies mapping functions to a map and returns the new, transformed map. See MapMapFn and SliceMapFn for explanations of the mapping function parameters. Either or both may be nil, but note that maps may contain slices, which is why JsonMap.Map() allows you to specify mapping functions for both maps and slices.
func (*JsonMap) SetBoolAtPath ¶
SetBoolAtPath sets a bool value in the map at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Note that map paths should always begin with a key. e.g. "keyForMap.keyForValue" (map with a map with a value) or "keyForValueSlice[0]" (map with a slice of values) or "keyForMap.keyForValueSlice[0]" (map with a map with a slice of values)
func (*JsonMap) SetFloatAtPath ¶
SetFloatAtPath sets a float value in the map at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Note that map paths should always begin with a key. e.g. "keyForMap.keyForValue" (map with a map with a value) or "keyForValueSlice[0]" (map with a slice of values) or "keyForMap.keyForValueSlice[0]" (map with a map with a slice of values)
func (*JsonMap) SetIntAtPath ¶
SetIntAtPath sets an int value in the map at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Note that map paths should always begin with a key. e.g. "keyForMap.keyForValue" (map with a map with a value) or "keyForValueSlice[0]" (map with a slice of values) or "keyForMap.keyForValueSlice[0]" (map with a map with a slice of values)
func (*JsonMap) SetMap ¶
SetMap sets a map with the specified key in the map. Use caution with this method. If you add a map that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the map.
func (*JsonMap) SetMapAtPath ¶
SetMapAtPath sets a JsonMap value in the map at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Use caution with this method. If you add a map that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the map. Note that map paths should always begin with a key. e.g. "keyForMap.keyForValue" (map with a map with a value) or "keyForValueSlice[0]" (map with a slice of values) or "keyForMap.keyForValueSlice[0]" (map with a map with a slice of values)
func (*JsonMap) SetSlice ¶
SetSlice sets a slice with the specified key in the map. It will only return an error if an empty key is provided. Use caution with this method. If you add a slice that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the map.
func (*JsonMap) SetSliceAtPath ¶
SetSliceAtPath sets a JsonSlice value in the map at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Use caution with this method. If you add a slice that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the map. Note that map paths should always begin with a key. e.g. "keyForMap.keyForValue" (map with a map with a value) or "keyForValueSlice[0]" (map with a slice of values) or "keyForMap.keyForValueSlice[0]" (map with a map with a slice of values)
func (*JsonMap) SetStringAtPath ¶
SetStringAtPath sets a string value in the map at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Note that map paths should always begin with a key. e.g. "keyForMap.keyForValue" (map with a map with a value) or "keyForValueSlice[0]" (map with a slice of values) or "keyForMap.keyForValueSlice[0]" (map with a map with a slice of values)
func (*JsonMap) SetValue ¶
SetValue sets an object of any type with the specified key in the map. Use caution with this method. If you add an object that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the map.
func (*JsonMap) SetValueAtPath ¶
SetValueAtPath sets an object of any type in the map at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Use caution with this method. If you add an object that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the map. Note that map paths should always begin with a key. e.g. "keyForMap.keyForValue" (map with a map with a value) or "keyForValueSlice[0]" (map with a slice of values) or "keyForMap.keyForValueSlice[0]" (map with a map with a slice of values)
func (*JsonMap) ToIoWriter ¶
func (*JsonMap) ToJsonBytes ¶
type JsonSlice ¶
type JsonSlice []interface{}
func NewJsonSliceFromIoReader ¶
NewJsonSliceFromIoReader creates a JsonSlice from an io.Reader. It returns an error if valid JSON cannot be decoded from the io.Reader. Note: This function expects the top-level JSON object to be a slice and will fail if it is a map (use NewJsonMapFromIoReader for a top-level map).
func NewJsonSliceFromJsonBytes ¶
NewJsonSliceFromJsonBytes creates a JsonSlice from an io.Reader. It returns an error if valid JSON cannot be decoded from the io.Reader. Note: This function expects the top-level JSON object to be a slice and will fail if it is a map (use NewJsonMapFromJsonBytes for a top-level map).
func NewJsonSliceFromJsonString ¶
NewJsonSliceFromJsonString creates a JsonSlice from an io.Reader. It returns an error if valid JSON cannot be decoded from the io.Reader. Note: This function expects the top-level JSON object to be a slice and will fail if it is a map (use NewJsonMapFromJsonString for a top-level map).
func NewJsonSliceFromSlice ¶
NewJsonSliceFromSlice creates a JsonSlice from a slice of any type
func (*JsonSlice) GetBool ¶
GetBool retrieves, from the slice, a bool at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a bool.
func (*JsonSlice) GetBoolAtPath ¶
GetBoolAtPath retrieves, from the slice, a bool at the specified path. It will return an error if the path is invalid or if the value at the path is not a bool. Note that slice paths should always begin with an array index. e.g. "[0].keyForBool" (slice of maps with bool value) or "[0][0]" (slice of slices of bool values)
func (*JsonSlice) GetBoolAtPathWithDefault ¶
GetBoolAtPathWithDefault retrieves, from the slice, a bool at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a bool. Note that slice paths should always begin with an array index. e.g. "[0].keyForBool" (slice of maps with bool value) or "[0][0]" (slice of slices of bool values)
func (*JsonSlice) GetBoolWithDefault ¶
GetBoolWithDefault retrieves, from the slice, a bool at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a bool.
func (*JsonSlice) GetFloat ¶
GetFloat retrieves, from the slice, a float at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a float (if the value at the index is an int, it will be quietly converted to a float).
func (*JsonSlice) GetFloatAtPath ¶
GetFloatAtPath retrieves, from the slice, a float at the specified path. It will return an error if the path is invalid or if the value at the path is not a float (if the value at the index is an int, it will be quietly converted to a float). Note that slice paths should always begin with an array index. e.g. "[0].keyForFloat" (slice of maps with float value) or "[0][0]" (slice of slices of float values)
func (*JsonSlice) GetFloatAtPathWithDefault ¶
GetFloatAtPathWithDefault retrieves, from the slice, a float at the specified path. It will return an error if the value at the path is not a float (if the value at the index is an int, it will be quietly converted to a float). Note that slice paths should always begin with an array index. e.g. "[0].keyForFloat" (slice of maps with float value) or "[0][0]" (slice of slices of float values)
func (*JsonSlice) GetFloatWithDefault ¶
GetFloatWithDefault retrieves, from the slice, a float at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a float (if the value at the index is an int, it will be quietly converted to a float).
func (*JsonSlice) GetInt ¶
GetInt retrieves, from the slice, an int at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not an int.
func (*JsonSlice) GetIntAtPath ¶
GetIntAtPath retrieves, from the slice, an int at the specified path. It will return an error if the path is invalid or if the value at the path is not an int. Note that slice paths should always begin with an array index. e.g. "[0].keyForInt" (slice of maps with int value) or "[0][0]" (slice of slices of int values)
func (*JsonSlice) GetIntAtPathWithDefault ¶
GetIntAtPathWithDefault retrieves, from the slice, an int at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not an int. Note that slice paths should always begin with an array index. e.g. "[0].keyForInt" (slice of maps with int value) or "[0][0]" (slice of slices of int values)
func (*JsonSlice) GetIntWithDefault ¶
GetIntWithDefault retrieves, from the slice, an int at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not an int.
func (*JsonSlice) GetMap ¶
GetMap retrieves, from the slice, a JsonMap at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonMap.
func (*JsonSlice) GetMapAtPath ¶
GetMapAtPath retrieves, from the slice, a JsonMap at the specified path. It will return an error if the path is invalid or if the value at the path is not a JsonMap. Note that slice paths should always begin with an array index. e.g. "[0].keyForMap" (slice of maps with map value) or "[0][0]" (slice of slices of map values)
func (*JsonSlice) GetMapAtPathWithDefault ¶
GetMapAtPathWithDefault retrieves, from the slice, a JsonMap at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonMap. Note that slice paths should always begin with an array index. e.g. "[0].keyForMap" (slice of maps with map value) or "[0][0]" (slice of slices of map values)
func (*JsonSlice) GetMapWithDefault ¶
GetMapWithDefault retrieves, from the slice, a JsonMap at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonMap.
func (*JsonSlice) GetSlice ¶
GetSlice retrieves, from the slice, a JsonSlice at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice.
func (*JsonSlice) GetSliceAtPath ¶
GetSliceAtPath retrieves, from the slice, a JsonSlice at the specified path. It will return an error if the path is invalid or if the value at the path is not a JsonSlice. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceAtPathWithDefault ¶
func (s *JsonSlice) GetSliceAtPathWithDefault(path string, defaultValue JsonSlice) (JsonSlice, error)
GetSliceAtPathWithDefault retrieves, from the slice, a JsonSlice at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfBools ¶
GetSliceOfBools retrieves, from the slice, a []bool at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a bool.
func (*JsonSlice) GetSliceOfBoolsAtPath ¶
GetSliceOfBoolsAtPath retrieves, from the slice, a []bool at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a bool. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfBoolsAtPathWithDefault ¶
func (s *JsonSlice) GetSliceOfBoolsAtPathWithDefault(path string, defaultValue []bool) ([]bool, error)
GetSliceOfBoolsAtPathWithDefault retrieves, from the slice, a []bool at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a bool. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfBoolsWithDefault ¶
GetSliceOfBoolsWithDefault retrieves, from the slice, a []bool at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a bool.
func (*JsonSlice) GetSliceOfFloats ¶
GetSliceOfFloats retrieves, from the slice, a []float64 at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a float64 (or an int64, which will be quietly converted to a float64).
func (*JsonSlice) GetSliceOfFloatsAtPath ¶
GetSliceOfFloatsAtPath retrieves, from the slice, a []float64 at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a float. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfFloatsAtPathWithDefault ¶
func (s *JsonSlice) GetSliceOfFloatsAtPathWithDefault(path string, defaultValue []float64) ([]float64, error)
GetSliceOfFloatsAtPathWithDefault retrieves, from the slice, a []float64 at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a float. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfFloatsWithDefault ¶
func (s *JsonSlice) GetSliceOfFloatsWithDefault(index int, defaultValue []float64) ([]float64, error)
GetSliceOfFloatsWithDefault retrieves, from the slice, a []float64 at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a float64 (or an int64, which will be quietly converted to a float64).
func (*JsonSlice) GetSliceOfInts ¶
GetSliceOfInts retrieves, from the slice, a []int64 at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not an int64.
func (*JsonSlice) GetSliceOfIntsAtPath ¶
GetSliceOfIntsAtPath retrieves, from the slice, a []int64 at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not an int. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfIntsAtPathWithDefault ¶
func (s *JsonSlice) GetSliceOfIntsAtPathWithDefault(path string, defaultValue []int64) ([]int64, error)
GetSliceOfIntsAtPathWithDefault retrieves, from the slice, a []int64 at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not an int. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfIntsWithDefault ¶
GetSliceOfIntsWithDefault retrieves, from the slice, a []int64 at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not an int64.
func (*JsonSlice) GetSliceOfMaps ¶
GetSliceOfMaps retrieves, from the slice, a []JsonMap at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a JsonMap.
func (*JsonSlice) GetSliceOfMapsAtPath ¶
GetSliceOfMapsAtPath retrieves, from the slice, a []JsonMap at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a map. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfMapsAtPathWithDefault ¶
func (s *JsonSlice) GetSliceOfMapsAtPathWithDefault(path string, defaultValue []JsonMap) ([]JsonMap, error)
GetSliceOfMapsAtPathWithDefault retrieves, from the slice, a []JsonMap at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a map. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfMapsWithDefault ¶
GetSliceOfMapsWithDefault retrieves, from the slice, a []JsonMap at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a JsonMap.
func (*JsonSlice) GetSliceOfSlices ¶
GetSliceOfSlices retrieves, from the slice, a []JsonSlice at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a JsonSlice.
func (*JsonSlice) GetSliceOfSlicesAtPath ¶
GetSliceOfSlicesAtPath retrieves, from the slice, a []JsonSlice at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a slice. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfSlicesAtPathWithDefault ¶
func (s *JsonSlice) GetSliceOfSlicesAtPathWithDefault(path string, defaultValue []JsonSlice) ([]JsonSlice, error)
GetSliceOfSlicesAtPathWithDefault retrieves, from the slice, a []JsonSlice at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a slice. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfSlicesWithDefault ¶
func (s *JsonSlice) GetSliceOfSlicesWithDefault(index int, defaultValue []JsonSlice) ([]JsonSlice, error)
GetSliceOfSlicesWithDefault retrieves, from the slice, a []JsonSlice at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a JsonSlice.
func (*JsonSlice) GetSliceOfStrings ¶
GetSliceOfStrings retrieves, from the slice, a []string at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a string.
func (*JsonSlice) GetSliceOfStringsAtPath ¶
GetSliceOfStringsAtPath retrieves, from the slice, a []string at the specified path. It will return an error if the path is invalid, if the value at the path is not a JsonSlice, or if any value in the slice is not a string. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfStringsAtPathWithDefault ¶
func (s *JsonSlice) GetSliceOfStringsAtPathWithDefault(path string, defaultValue []string) ([]string, error)
GetSliceOfStringsAtPathWithDefault retrieves, from the slice, a []string at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a JsonSlice or if any value in the slice is not a string. Note that slice paths should always begin with an array index. e.g. "[0].keyForSlice" (slice of maps with slice value) or "[0][0]" (slice of slices of slice values)
func (*JsonSlice) GetSliceOfStringsWithDefault ¶
func (s *JsonSlice) GetSliceOfStringsWithDefault(index int, defaultValue []string) ([]string, error)
GetSliceOfStringsWithDefault retrieves, from the slice, a []string at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice or if any value in the slice is not a string.
func (*JsonSlice) GetSliceWithDefault ¶
GetSliceWithDefault retrieves, from the slice, a JsonSlice at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a JsonSlice.
func (*JsonSlice) GetString ¶
GetString retrieves, from the slice, a string at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a string.
func (*JsonSlice) GetStringAtPath ¶
GetStringAtPath retrieves, from the slice, a string at the specified path. It will return an error if the path is invalid or if the value at the path is not a string. Note that slice paths should always begin with an array index. e.g. "[0].keyForString" (slice of maps with string value) or "[0][0]" (slice of slices of string values)
func (*JsonSlice) GetStringAtPathWithDefault ¶
GetStringAtPathWithDefault retrieves, from the slice, a string at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. It will return an error if the value at the path is not a string. Note that slice paths should always begin with an array index. e.g. "[0].keyForString" (slice of maps with string value) or "[0][0]" (slice of slices of string values)
func (*JsonSlice) GetStringWithDefault ¶
GetStringWithDefault retrieves, from the slice, a string at the specified index. It will return an error if the index is out of bounds for the slice or if the value at the index is not a string.
func (*JsonSlice) GetValue ¶
GetValue retrieves, from the slice, an object of any type at the specified index. It will return an error if the index is out of bounds for the slice.
func (*JsonSlice) GetValueAtPath ¶
GetValueAtPath retrieves, from the slice, an object of any type at the specified path. It will return an error if the path is invalid. Note that slice paths should always begin with an array index. e.g. "[0].keyForValue" (slice of maps with value) or "[0][0]" (slice of slices of values)
func (*JsonSlice) GetValueAtPathWithDefault ¶
GetValueAtPathWithDefault retrieves, from the slice, an object of any type at the specified path. If the value cannot be found for any reason (including an invalid path), then it returns the default value. Note that slice paths should always begin with an array index. e.g. "[0].keyForValue" (slice of maps with value) or "[0][0]" (slice of slices of values)
func (*JsonSlice) GetValueWithDefault ¶
GetValueWithDefault retrieves, from the slice, an object of any type at the specified index. If the index is out of bounds, then it returns the default value.
func (*JsonSlice) Map ¶
func (s *JsonSlice) Map(mapMapFn MapMapFn, sliceMapFn SliceMapFn) JsonSlice
Map recursively applies mapping functions to a map and returns the new, transformed map. See MapMapFn and SliceMapFn for explanations of the mapping function parameters. Either or both may be nil, but note that slices may contain maps, which is why JsonSlice.Map() allows you to specify mapping functions for both slices and maps.
func (*JsonSlice) SetBool ¶
SetBool sets a bool at the specified index in the slice. It will not grow the slice, and it will return an error if the index is out of bounds for the slice.
func (*JsonSlice) SetBoolAtPath ¶
SetBoolAtPath sets a bool at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Note that slice paths should always begin with an index. e.g. "[0].keyForValue" (slice of maps with value) or "[0][0]" (slice of slices of values)
func (*JsonSlice) SetFloat ¶
SetFloat sets a float at the specified index in the slice. It will not grow the slice, and it will return an error if the index is out of bounds for the slice.
func (*JsonSlice) SetFloatAtPath ¶
SetFloatAtPath sets a float at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Note that slice paths should always begin with an index. e.g. "[0].keyForValue" (slice of maps with value) or "[0][0]" (slice of slices of values)
func (*JsonSlice) SetInt ¶
SetInt sets an int at the specified index in the slice. It will not grow the slice, and it will return an error if the index is out of bounds for the slice.
func (*JsonSlice) SetIntAtPath ¶
SetIntAtPath sets an int at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Note that slice paths should always begin with an index. e.g. "[0].keyForValue" (slice of maps with value) or "[0][0]" (slice of slices of values)
func (*JsonSlice) SetMap ¶
SetMap sets a JsonMap at the specified index in the slice. It will not grow the slice, and it will return an error if the index is out of bounds for the slice. Use caution with this method. If you add a map that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the slice.
func (*JsonSlice) SetMapAtPath ¶
SetMapAtPath sets a JsonMap at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Use caution with this method. If you add a map that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the slice. Note that slice paths should always begin with an index. e.g. "[0].keyForValue" (slice of maps with value) or "[0][0]" (slice of slices of values)
func (*JsonSlice) SetSlice ¶
SetSlice sets a JsonSlice at the specified index in the slice. It will not grow the slice, and it will return an error if the index is out of bounds for the slice. Use caution with this method. If you add a slice that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the slice.
func (*JsonSlice) SetSliceAtPath ¶
SetSliceAtPath ses a JsonSlice at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Use caution with this method. If you add a slice that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the slice. Note that slice paths should always begin with an index. e.g. "[0].keyForValue" (slice of maps with value) or "[0][0]" (slice of slices of values)
func (*JsonSlice) SetString ¶
SetString sets a string at the specified index in the slice. It will not grow the slice, and it will return an error if the index is out of bounds for the slice.
func (*JsonSlice) SetStringAtPath ¶
SetStringAtPath sets a string at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Note that slice paths should always begin with an index. e.g. "[0].keyForValue" (slice of maps with value) or "[0][0]" (slice of slices of values)
func (*JsonSlice) SetValue ¶
SetValue sets an object of any type at the specified index in the slice. It will not grow the slice, and it will return an error if the index is out of bounds for the slice. Use caution with this method. If you add an object that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the slice.
func (*JsonSlice) SetValueAtPath ¶
SetValueAtPath sets an object of any type at the specified path. It will attempt to create missing intermediate map elements of the path. It will fail to create missing intermediate slice elements. Use caution with this method. If you add an object that contains invalid Json elements (e.g. arbitrary structs or pointers to objects), then you may break the ability to traverse the slice. Note that slice paths should always begin with an index. e.g. "[0].keyForValue" (slice of maps with value) or "[0][0]" (slice of slices of values)
func (*JsonSlice) ToIoWriter ¶
func (*JsonSlice) ToJsonBytes ¶
type MapMapFn ¶
type MapMapFn func(elementPath []interface{}, ancestorSliceIndex int, key string, value interface{}) ( newKey string, newValue interface{}, )
MapMapFn is the signature for a callback that the JsonMap.Map() function recursively applies to map keys/values. Callback implementations may mutate the key and value parameters by returning new values for either or both. The callback may also delete a key by returning an empty string for the new key name.
As mapping proceeds, the elementPath parameter reflects the path of the current element's parent. The elementPath can be a mix of strings and ints, where strings represent map keys and ints represent slice indices. If the current map is located within a slice (either directly or as a nested element of an element within a slice), the ancestorSliceIndex parameter will be >= 0 to represent the index of the current map within the nearest slice (otherwise it will be < 0). This can be used, for example, to set a map's key or value to something reflecting its position in the slice. You could extract ancestorSliceIndex from elementPath; however, it is provided separately as a convenience.
Example:
{ "Key1": [ { "Key2": { "Key3: 1 } }, { "Key4": { "Key5: 2 } } ] }
When MapMapFn is called for Key1, elementPath will be [] and ancestorSliceIndex will be -1 When MapMapFn is called for Key3, elementPath will be ["Key1", 0, "Key2"] and ancestorSliceIndex will be 0 When MapMapFn is called for Key5, elementPath will be ["Key1", 1, "Key4"] and ancestorSliceIndex will be 1
type SliceMapFn ¶
type SliceMapFn func(elementPath []interface{}, ancestorSliceIndex int, index int, value interface{}) ( newValue interface{}, keepValue bool, )
SliceMapFn is the signature for a callback that the JsonMap.Map() function recursively applies to slice values. Callback implementations may mutate the value by returning a new one. Callbacks may also drop a value from a slice by returning false for the "keepValue" return value.
As mapping proceeds, the elementPath parameter reflects the path of the current element's parent. The elementPath can be a mix of strings and ints, where strings represent map keys and ints represent slice indices. If the current slice is located within a slice (either directly or as a nested element of an element within a slice), the ancestorSliceIndex parameter will be >= 0 to represent the index of the current slice within the nearest slice (otherwise it will be < 0). This can be used, for example, to set a slice's value to something reflecting its position in the slice. You could extract ancestorSliceIndex from elementPath; however, it is provided separately as a convenience.
Example:
{ "Key1": [ { "Key2": { "Key3: 1 } }, { "Key4": { "Key5: 2 } } ] }
When MapMapFn is called for Key1, elementPath will be [] and ancestorSliceIndex will be -1 When MapMapFn is called for Key3, elementPath will be ["Key1", 0, "Key2"] and ancestorSliceIndex will be 0 When MapMapFn is called for Key5, elementPath will be ["Key1", 1, "Key4"] and ancestorSliceIndex will be 1