Documentation ¶
Index ¶
Constants ¶
View Source
const ( TagPathName = "path" TagPathValueRequired = "required" PathArrayFirst = "0" )
Variables ¶
View Source
var ( ErrorInvalidJSONFormat = errors.New("invalid json format") ErrorNotFound = errors.New("data not found for the path") ErrorMissingRequired = errors.New("missing required field") ErrorUnsupportedFieldType = errors.New("unsupported field type") ErrorNotAnArray = errors.New("data is not an array") )
Functions ¶
func ToJsonString ¶
func ToJsonString(v interface{}) string
func ValidateString ¶
Types ¶
type Json ¶
type Json interface { // Raw JSON message Raw() json.RawMessage // Raw string RawString() string // True if the instance is null IsNull() bool // Returns an array value and true if this instance is an array. Array() (v []Json, t bool) // Run each entries ArrayEach(f func(e Json) error) error // Returns an object value and true if this instance is an object. Object() (v map[string]Json, t bool) // Returns an boolean value and true if this instance is true/false. Bool() (v bool, t bool) // Returns a number value and true if this instance is a number. Number() (v es_number.Number, t bool) // Returns a string value and true if this instance is a string. String() (v string, t bool) // Parse model with given type. Model(v interface{}) (err error) // Find value under the path. Returns nil & false if not found. Find(path string) (j Json, found bool) // Find then Model. FindModel(path string, v interface{}) (err error) // Find an array FindArray(path string) (v []Json, t bool) // Find an array FindArrayEach(path string, f func(e Json) error) error // Find an object FindObject(path string) (v map[string]Json, t bool) // Find Bool FindBool(path string) (v bool, t bool) // Returns a number value and true if this instance is a number. FindNumber(path string) (v es_number.Number, t bool) // Returns a string value and true if this instance is a string. FindString(path string) (v string, t bool) }
Wrapper of gjson
func MustParseString ¶
func ParseString ¶
Click to show internal directories.
Click to hide internal directories.