Documentation
¶
Overview ¶
Package jsonextract is a library for extracting any valid JSONs from given source
Index ¶
- Constants
- func Save(data []*JSON) error
- func SaveToPath(data []*JSON, path string) error
- type JSON
- func (json *JSON) AddField(key interface{}, val interface{})
- func (json *JSON) AddItem(val interface{})
- func (json *JSON) Array() []*JSON
- func (json *JSON) Boolean() bool
- func (json *JSON) Bytes() []byte
- func (json *JSON) DeleteField(key interface{}) bool
- func (json *JSON) DeleteItem(i int) bool
- func (json *JSON) Float() float64
- func (json *JSON) Integer() int64
- func (json *JSON) Kind() int
- func (json *JSON) Len() int
- func (json *JSON) Object() map[interface{}]*JSON
- func (json *JSON) Runes() []rune
- func (json *JSON) SetBool(b bool)
- func (json *JSON) SetFloat(i float64)
- func (json *JSON) SetInt(i int64)
- func (json *JSON) SetStr(str string)
- func (json *JSON) String() string
Constants ¶
const ( Object = iota Array String Integer Float Boolean Null )
JSON kinds
Variables ¶
This section is empty.
Functions ¶
func SaveToPath ¶
SaveToPath save extracted JSONs to a file path
Types ¶
type JSON ¶
type JSON struct {
// contains filtered or unexported fields
}
JSON represent json val
func FromReader ¶
FromReader extract JSONs from reader io.Reader
func (*JSON) AddField ¶
func (json *JSON) AddField(key interface{}, val interface{})
AddField add new field to object. Will panic if kind is not Object. Will panic if val is invalid json value. Valid key is string or integer type. If val is map, and key is not string nor an integer type, panic will occur
func (*JSON) AddItem ¶
func (json *JSON) AddItem(val interface{})
AddItem add new item in json array. Will panic if kind is not Array. Will panic if val is invalid json value
func (*JSON) DeleteField ¶
DeleteField delete object field by key. Will panic if kind is not Object. key must be string or an integer type, otherwise panic will occur
func (*JSON) DeleteItem ¶
DeleteItem delete element on index i. Will panic if kind is not Array. Will panic if i bigger than items count minus 1 (len(vals)-1, the last index). If item is existed, true is returned, otherwise false
func (*JSON) Len ¶
Len return items count inside JSON. If JSON is not Array or Object, Len will return 0, so please check the JSON kind first
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
array
command
|
|
boolean
command
|
|
edit-val/array
command
|
|
edit-val/object
command
|
|
heavy
command
|
|
null
command
|
|
numeric
command
|
|
object
command
|
|
string
command
|