json

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compact

func Compact(dst *bytes.Buffer, src RawValue) error

func Decode

func Decode(data []byte, v interface{}) (err error)

func EncodeAndStore

func EncodeAndStore(v interface{}, w interface{}, pretty ...bool) (r []byte, err error)

func EncodePrefix

func EncodePrefix(v interface{}, prefix string, pretty ...bool) (r []byte)

func GetFromFile

func GetFromFile(src string, path string) (g gjson.Result)

func MapToStruct

func MapToStruct(m any, target any) (err error)

func Marshal

func Marshal(v interface{}) ([]byte, error)

func Read

func Read(src string, v interface{}) (err error)

func Save

func Save(src string, data []byte) (err error)

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

func Valid

func Valid(src []byte) bool

Types

type MarshalJSON

type MarshalJSON = gojson.Marshaler

type Raw

type Raw = gojson.RawMessage

type RawValue

type RawValue []byte

func Encode

func Encode(v interface{}, pretty ...bool) (r RawValue)

func EncodeNoEscape

func EncodeNoEscape(v any) (r RawValue)

func EncodeWithColor

func EncodeWithColor(v any, pretty ...bool) (r RawValue)

func Load

func Load(src string) (data RawValue)

func LoadWithErr

func LoadWithErr(src string) (data RawValue, err error)

func (RawValue) Clean

func (o RawValue) Clean() (r RawValue)

func (RawValue) Delete

func (o RawValue) Delete(p string) RawValue

delete node by path it wont delete the original value unless it set to itself, ie: data = data.Delete(path)

func (RawValue) Format

func (o RawValue) Format(f fmt.State, verb rune)

func (RawValue) Get

func (o RawValue) Get(p string) (result Result)

get a node by path, borrowed from gjson.Get

func (RawValue) GetMany

func (o RawValue) GetMany(p ...string) (result []Result)

get more paths, similiar to Get but with multiple path

func (RawValue) Highlight

func (o RawValue) Highlight(query string) (r RawValue)

func (RawValue) Keys

func (o RawValue) Keys(p string) (result Result)

func (RawValue) Map

func (o RawValue) Map() (m map[string]any)

func (RawValue) Object

func (o RawValue) Object() Result

func (RawValue) Render

func (o RawValue) Render(template string, key string) (r RawValue)

get a node by path, borrowed from gjson.Get

func (RawValue) Set

func (o RawValue) Set(p string, value any) RawValue

set new node by path it wont overwrite the original value unless it set to itself, ie: data = data.Set(path, 1234)

func (RawValue) Size

func (o RawValue) Size() (size string)

func (RawValue) String

func (o RawValue) String() string

func (RawValue) Value

func (o RawValue) Value() any

type Result

type Result struct {
	gjson.Result
}

type UnmarshalJSON

type UnmarshalJSON = gojson.Unmarshaler

Jump to

Keyboard shortcuts

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