Documentation ¶
Overview ¶
kbjson2Json data read and write operations
Index ¶
- Constants
- Variables
- func AddModifier(name string, fn func(json, arg string) string)
- func Bytes2String(b []byte) string
- func Delete(json, path string) (string, error)
- func DeleteBytes(json []byte, path string) ([]byte, error)
- func Discard(json string) (string, error)
- func ForEachLine(json string, iterator func(line JsonRes) bool)
- func Format(json []byte) []byte
- func FormatOptions(json []byte, opts *StFormatOptions) []byte
- func Len(str string) int
- func Marshal(json interface{}) ([]byte, error)
- func Match(str, pattern string) bool
- func ModifierExists(name string) bool
- func ModifiersState() bool
- func Pad(raw string, length int, padStr string, padType int) string
- func Set(json, path string, value interface{}) (string, error)
- func SetBytes(json []byte, path string, value interface{}) ([]byte, error)
- func SetBytesOptions(json []byte, path string, value interface{}, opts *Options) ([]byte, error)
- func SetModifiersState(b bool)
- func SetOptions(json, path string, value interface{}, opts *Options) (string, error)
- func SetRaw(json, path, value string) (string, error)
- func SetRawBytes(json []byte, path string, value []byte) ([]byte, error)
- func SetRawBytesOptions(json []byte, path string, value []byte, opts *Options) ([]byte, error)
- func SetRawOptions(json, path, value string, opts *Options) (string, error)
- func String2Bytes(s string) []byte
- func Stringify(value interface{}) (json string)
- func TrimSpace(s string) string
- func Ugly(json []byte) []byte
- func Unmarshal(json, v interface{}) error
- func UnmarshalValidationEnabled(enabled bool)
- func Valid(json string) (ok bool)
- func ValidBytes(json []byte) bool
- type JsonRes
- func (r JsonRes) Array() []JsonRes
- func (r JsonRes) Bool() bool
- func (r JsonRes) Exists() bool
- func (r JsonRes) Float() float64
- func (r JsonRes) ForEach(iterator func(key, value JsonRes) bool)
- func (r JsonRes) Get(path string) JsonRes
- func (r JsonRes) Int() int
- func (r JsonRes) IsArray() bool
- func (r JsonRes) IsObject() bool
- func (r JsonRes) Map() map[string]JsonRes
- func (r JsonRes) String() string
- func (r JsonRes) Time(format ...string) time.Time
- func (r JsonRes) Uint() uint
- func (r JsonRes) Unmarshal(v interface{}) error
- func (r JsonRes) Value() interface{}
- type Map
- type Options
- type StFormatOptions
- type Type
Constants ¶
View Source
const ( PadRight int = iota //向右填充字符 PadLeft //向左填充字符 )
Variables ¶
View Source
var ( DefOptions = &StFormatOptions{Width: 80, Prefix: "", Indent: " ", SortKeys: false} Matches = []Map{ {"start": "//", "end": "\n"}, {"start": "/*", "end": "*/"}, } )
View Source
var ( ErrNoChange = errors.New("no change") ErrPathEmpty = errors.New("path cannot be empty") ErrInvalidJSON = errors.New("invalid json") ErrNotAllowedWildcard = errors.New("wildcard characters not allowed in path") ErrNotAllowedArrayAccess = errors.New("array access character not allowed in path") ErrTypeError = errors.New("json must be an object or array") )
Functions ¶
func AddModifier ¶
func ForEachLine ¶
func FormatOptions ¶
func FormatOptions(json []byte, opts *StFormatOptions) []byte
func ModifierExists ¶
func ModifiersState ¶
func ModifiersState() bool
func SetBytesOptions ¶
func SetModifiersState ¶
func SetModifiersState(b bool)
func SetOptions ¶
func SetRawBytesOptions ¶
func UnmarshalValidationEnabled ¶
func UnmarshalValidationEnabled(enabled bool)
func ValidBytes ¶
Types ¶
type StFormatOptions ¶
Click to show internal directories.
Click to hide internal directories.