jsonp: github.com/disksing/jsonp Index | Files

package jsonp

import "github.com/disksing/jsonp"

Index

Package Files

jsonp.go

func Test Uses

func Test(x Any, path []string, value Any) error

Test checks if a node value is the same as expect.

func TestByPointer Uses

func TestByPointer(x Any, pointer string, value Any) error

TestByPointer checks if a node value is the same as expect. The position is specified by JSON Pointer.

func ToPath Uses

func ToPath(pointer string) ([]string, error)

ToPath converts JSON Pointer to path.

func ToPointer Uses

func ToPointer(path []string) string

ToPointer converts path to JSON Pointer.

func Walk Uses

func Walk(x Any, f func(path []string, x Any) bool)

Walk applies f to all sub nodes of x.

func WalkByPointer Uses

func WalkByPointer(x Any, f func(pointer string, x Any) bool)

WalkByPointer applies f to all sub nodes of x.

func WalkMatch Uses

func WalkMatch(x Any, re *regexp.Regexp, f func(string, Any) bool)

WalkMatch applies f to all nodes with JSON pointer matches given pattern.

type Any Uses

type Any = interface{}

JSON types.

func Add Uses

func Add(x Any, path []string, value Any) (Any, error)

Add inserts value at given position.

func AddByPointer Uses

func AddByPointer(x Any, pointer string, value Any) (Any, error)

AddByPointer inserts value at given position. The position is specified by JSON Pointer.

func ApplyPatch Uses

func ApplyPatch(x Any, patch Patch) (Any, error)

ApplyPatch applies a JSON patch to a JSON node and returns a new one. Note that the old node will be updated too.

func Clone Uses

func Clone(x Any) Any

Clone makes a copy of a JSON node.

func Copy Uses

func Copy(x Any, from, to []string) (Any, error)

Copy copies a node to another position.

func CopyByPointer Uses

func CopyByPointer(x Any, from, to string) (Any, error)

CopyByPointer copies a node to another position. The positions are specified by JSON Pointer.

func Get Uses

func Get(x Any, path []string) (Any, error)

Get retrieves a node by path.

func GetByPointer Uses

func GetByPointer(x Any, pointer string) (Any, error)

GetByPointer retrieves node by JSON Pointer.

func Move Uses

func Move(x Any, from, to []string) (Any, error)

Move moves a node to another position.

func MoveByPointer Uses

func MoveByPointer(x Any, from, to string) (Any, error)

MoveByPointer moves a node to another position. The positions are specified by JSON Pointer.

func Remove Uses

func Remove(x Any, path []string) (Any, error)

Remove removes node from given position.

func RemoveByPointer Uses

func RemoveByPointer(x Any, pointer string) (Any, error)

RemoveByPointer removes node from given position. The position is specified by JSON Pointer.

func Replace Uses

func Replace(x Any, path []string, value Any) (Any, error)

Replace replaces node by new value at given position.

func ReplaceByPointer Uses

func ReplaceByPointer(x Any, pointer string, value Any) (Any, error)

ReplaceByPointer replaces node by new value at given position. The position is specified by JSON Pointer.

type Array Uses

type Array = []Any

JSON types.

type Object Uses

type Object = map[string]Any

JSON types.

type Patch Uses

type Patch []PatchOperation

Patch is a JSON Patch.

type PatchOperation Uses

type PatchOperation struct {
    Op    string `json:"op"`
    Path  string `json:"path"`
    Value Any    `json:"value,omitempty"`
    From  string `json:"from,omitempty"`
}

PatchOperation represents an item in JSON Patch.

Package jsonp imports 5 packages (graph). Updated 2019-08-05. Refresh now. Tools for package owners.