jsontool

package
v1.13.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2023 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONData

type JSONData struct {
	// contains filtered or unexported fields
}

JSONData represent a whole Json construct.

func NewJSONData

func NewJSONData(jsonData []byte) (*JSONData, error)

NewJSONData will create a new instance of JSONData

func (*JSONData) Get

func (jo *JSONData) Get(path string) *JSONNode

Get will retrieve the json node indicated by a path

func (*JSONData) GetBool

func (jo *JSONData) GetBool(path string) (bool, error)

GetBool will get the bool value from a json indicated by specified path. Error returned if path is not valid.

func (*JSONData) GetFloat

func (jo *JSONData) GetFloat(path string) (float64, error)

GetFloat will get the float value from a json indicated by specified path. Error returned if path is not valid.

func (*JSONData) GetInt

func (jo *JSONData) GetInt(path string) (int, error)

GetInt will get the int value from a json indicated by specified path. Error returned if path is not valid.

func (*JSONData) GetRootNode

func (jo *JSONData) GetRootNode() *JSONNode

GetRootNode will return the root node of this JSONData

func (*JSONData) GetString

func (jo *JSONData) GetString(path string) (string, error)

GetString will get the string value from a json indicated by specified path. Error returned if path is not valid.

func (*JSONData) IsArray

func (jo *JSONData) IsArray(path string) (bool, error)

IsArray will check if the node indicated by specified path is an Array node

func (*JSONData) IsBool

func (jo *JSONData) IsBool(path string) (bool, error)

IsBool will check if the node indicated by specified path is a bool node

func (*JSONData) IsFloat

func (jo *JSONData) IsFloat(path string) (bool, error)

IsFloat will check if the node indicated by specified path is a float node

func (*JSONData) IsInt

func (jo *JSONData) IsInt(path string) (bool, error)

IsInt will check if the node indicated by specified path is an int node

func (*JSONData) IsMap

func (jo *JSONData) IsMap(path string) (bool, error)

IsMap will check if the node indicated by specified path is a map node

func (*JSONData) IsString

func (jo *JSONData) IsString(path string) (bool, error)

IsString will check if the node indicated by specified path is a string node

func (*JSONData) IsValidPath

func (jo *JSONData) IsValidPath(path string) bool

IsValidPath will check if the provided path is valid

func (*JSONData) SetBool

func (jo *JSONData) SetBool(path string, value bool) error

SetBool will set the node at specified path with provided bool value

func (*JSONData) SetFloat

func (jo *JSONData) SetFloat(path string, value float64) error

SetFloat will set the node at specified path with provided float value

func (*JSONData) SetInt

func (jo *JSONData) SetInt(path string, value int) error

SetInt will set the node at specified path with provided int value

func (*JSONData) SetString

func (jo *JSONData) SetString(path, value string) error

SetString will set the node at specified path with provided string value

type JSONNode

type JSONNode struct {
	// contains filtered or unexported fields
}

JSONNode represent a node in JSON Tree

func (*JSONNode) Get

func (n *JSONNode) Get(key string) *JSONNode

Get will fetch the child not designated with specified key. Will panic if this node is not a map

func (*JSONNode) GetBool

func (n *JSONNode) GetBool() bool

GetBool will get the bool value of this node. Will panic if this node is not a boolean

func (*JSONNode) GetFloat

func (n *JSONNode) GetFloat() float64

GetFloat will get the float value of this node. Will panic if this node is not a float.

func (*JSONNode) GetInt

func (n *JSONNode) GetInt() int

GetInt will get the int value of this node. Will panic if this node is not an int

func (*JSONNode) GetNodeAt

func (n *JSONNode) GetNodeAt(index int) *JSONNode

GetNodeAt will get the child not on specific index. Will panic if this not is not an array

func (*JSONNode) GetString

func (n *JSONNode) GetString() string

GetString will get the string value of this node. Will panic if this node is not a string

func (*JSONNode) HaveKey

func (n *JSONNode) HaveKey(key string) bool

HaveKey will check if the map contains specified key. Will panic if this node is not a map

func (*JSONNode) IsArray

func (n *JSONNode) IsArray() bool

IsArray will check if this node represent an array

func (*JSONNode) IsBool

func (n *JSONNode) IsBool() bool

IsBool check if this node represent a boolean

func (*JSONNode) IsFloat

func (n *JSONNode) IsFloat() bool

IsFloat check if this node represent a float

func (*JSONNode) IsInt

func (n *JSONNode) IsInt() bool

IsInt checks if this node represent an int

func (*JSONNode) IsMap

func (n *JSONNode) IsMap() bool

IsMap will check if this node represent a Map

func (*JSONNode) IsString

func (n *JSONNode) IsString() bool

IsString check if this node represent a string

func (*JSONNode) Len

func (n *JSONNode) Len() int

Len return length of element in this array. Will panic if this node is not an array

func (*JSONNode) Set

func (n *JSONNode) Set(key string, node *JSONNode)

Set will set the value of a map designated with specified key. Will panic if this node is not a map

func (*JSONNode) SetBool

func (n *JSONNode) SetBool(val bool)

SetBool will set this node value with boolean value, will panic if this node is not a bool

func (*JSONNode) SetFloat

func (n *JSONNode) SetFloat(val float64)

SetFloat will set this node value with float value. Will panic if this node is not a float

func (*JSONNode) SetInt

func (n *JSONNode) SetInt(val int)

SetInt will set this node value with int value. Will panic if this node is not an int

func (*JSONNode) SetString

func (n *JSONNode) SetString(val string)

SetString will set this node value with a string value. Will panic if this node is not a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL