jsonpointer

package module
v0.19.6-0...-25e713f Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

gojsonpointer Build Status codecov Slack Status

license GoDoc An implementation of JSON Pointer - Go language

Status

Completed YES

Tested YES

References

http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07

Note

The 4.Evaluation part of the previous reference, starting with 'If the currently referenced value is a JSON array, the reference token MUST contain either...' is not implemented.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(token string) string

Escape escapes a pointer reference token string

func GetForToken

func GetForToken(document interface{}, decodedToken string) (interface{}, reflect.Kind, error)

GetForToken gets a value for a json pointer token 1 level deep

func SetForToken

func SetForToken(document interface{}, decodedToken string, value interface{}) (interface{}, error)

SetForToken gets a value for a json pointer token 1 level deep

func Unescape

func Unescape(token string) string

Unescape unescapes a json pointer reference token string to the original representation

Types

type JSONPointable

type JSONPointable interface {
	JSONLookup(string) (interface{}, error)
}

JSONPointable is an interface for structs to implement when they need to customize the json pointer process

type JSONSetable

type JSONSetable interface {
	JSONSet(string, interface{}) error
}

JSONSetable is an interface for structs to implement when they need to customize the json pointer process

type Pointer

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

Pointer the json pointer representation

func New

func New(jsonPointerString string) (Pointer, error)

New creates a new json pointer for the given string

@deprecated: use Parse() instead

func Parse

func Parse(jsonPointerString string) Pointer

Parse creates a new json pointer for the given string.

Parse is slightly more generous in what it accepts compared to New. The latter will error, iff, jsonPointerString starts with a `/`.

func (*Pointer) DecodedTokens

func (p *Pointer) DecodedTokens() []string

DecodedTokens returns the decoded tokens

func (*Pointer) Get

func (p *Pointer) Get(document interface{}) (interface{}, reflect.Kind, error)

Get uses the pointer to retrieve a value from a JSON document

func (*Pointer) IsEmpty

func (p *Pointer) IsEmpty() bool

IsEmpty returns true if this is an empty json pointer this indicates that it points to the root document

func (Pointer) MarshalJSON

func (p Pointer) MarshalJSON() ([]byte, error)

func (*Pointer) Set

func (p *Pointer) Set(document interface{}, value interface{}) (interface{}, error)

Set uses the pointer to set a value from a JSON document

func (*Pointer) String

func (p *Pointer) String() string

Pointer to string representation function

func (*Pointer) UnmarshalJSON

func (p *Pointer) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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