jsonlib

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

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

Cursor is a wrapper for gjson.Result providing easier interface for getting values from a JSON string in some use cases (ie. copying values on different types from JSON to structs). The wrapper may have some performance penalty compared to using directly gjson.Result but on the other hand it allows (domain specific) parsing code to be a bit less verbose.

func NewCursor

func NewCursor(result gjson.Result) Cursor

NewCursor creates a new cursor wrapping gjson.Result.

func (Cursor) Bool

func (c Cursor) Bool(path string) bool

Bool returns an element as a bool.

func (Cursor) Exists

func (c Cursor) Exists() bool

Exists returns true if the cursor points to an existing JSON value.

func (Cursor) Float32

func (c Cursor) Float32(path string) float32

Float32 returns an element as an float32.

func (Cursor) Float64

func (c Cursor) Float64(path string) float64

Float64 returns an element as an float64.

func (Cursor) ForEachArray

func (c Cursor) ForEachArray(path string, iterator func(value Cursor) bool)

ForEachArray iterates through array on a path location.

func (Cursor) Get

func (c Cursor) Get(path string) Cursor

Get returns a new cursor for a given path.

func (Cursor) Go

func (c Cursor) Go(path string) bool

Go moves the cursor to a new path location if such location exists (and returning true). If a new path location does not exits, returns false.

func (Cursor) Int32

func (c Cursor) Int32(path string) int32

Int32 returns an element as an int32.

func (Cursor) Int64

func (c Cursor) Int64(path string) int64

Int64 returns an element as an int64.

func (Cursor) IsArray

func (c Cursor) IsArray() bool

IsArray returns true if the cursor points to a JSON array.

func (Cursor) IsObject

func (c Cursor) IsObject() bool

IsObject returns true if the cursor points to a JSON object.

func (Cursor) Result

func (c Cursor) Result() gjson.Result

Result returns the gjson.Result the cursor is pointing at.

func (Cursor) String

func (c Cursor) String(path string) string

String returns an element as a string.

Jump to

Keyboard shortcuts

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