Documentation ¶
Index ¶
- Variables
- func DeepEquals(s1, s2 []byte) (bool, error)
- func Delete(json []byte, key string) (tmp []byte, err error)
- func Set(json []byte, key string, value interface{}) (tmp []byte, err error)
- func SetRaw(json []byte, key string, value interface{}) (tmp []byte, err error)
- func Valid(data interface{}) bool
- type Result
Constants ¶
This section is empty.
Variables ¶
var Types = map[gjson.Type]string{
0: "Null",
1: "Boolean",
2: "Number",
3: "String",
4: "Boolean",
5: "JSON",
}
Types maps gjson.Type to strings.
Functions ¶
func DeepEquals ¶
DeepEquals performs a deep equals comparison between two byte arrays.
func Set ¶
Set inserts values into JSON and operates under these conditions (in order):
- If the value is valid JSON (bytes, string, or Result), then it is inserted using SetRaw to properly insert it as nested JSON; this avoids encoding that would otherwise create invalid JSON (e.g. `{\"foo\":\"bar\"}`)
- If the value is bytes, then it is converted to a base64 encoded string (this is the behavior of the standard library's encoding/json package)
- If the value is Result, then it is converted to the underlying GJSON Value
- All other values are inserted as interfaces and are converted by SJSON to the proper format