jsonpointer

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2019 License: MIT Imports: 5 Imported by: 24 modules, 23 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-jsonpointer

Build Status Codecov GoDoc Go Report Card

Go implementation of JSON Pointer (RFC6901)

Usage

jsonpointer.Get(obj, pointer)

json := `
{
	"foo": [1,true,2]
}
`
var obj interface{}
json.Unmarshal([]byte(json), &obj)
jsonpointer.Get(obj, "/foo/1") // Should be true

jsonpointer.Set(obj, pointer, newvalue)

json := `
{
	"foo": [1,true,2]
}
`
var obj interface{}
json.Unmarshal([]byte(json), &obj)
jsonpointer.Set(obj, "/foo/1", false)
// obj should be {"foo":[1,false,2]}

jsonpointer.Remove(obj, pointer)

json := `
{
	"foo": [1,true,2]
}
`
var obj interface{}
json.Unmarshal([]byte(json), &obj)
jsonpointer.Remove(obj, "/foo/1")
// obj should be {"foo":[1,2]}

Installation

$ go get github.com/mattn/go-jsonpointer

License

MIT

Author

Yasuhiro Matsumoto (a.k.a mattn)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(obj interface{}, pointer string) (rv interface{}, err error)

Get return a value which is pointed with pointer on obj.

func Has

func Has(obj interface{}, pointer string) (rv bool)

Has return whether the obj has pointer.

func Remove

func Remove(obj interface{}, pointer string) (rv interface{}, err error)

Remove remove a value which is pointed with pointer on obj.

func Set

func Set(obj interface{}, pointer string, value interface{}) (err error)

Set set a value which is pointed with pointer on obj.

Types

This section is empty.

Directories

Path Synopsis
cmd
jsonpointer command

Jump to

Keyboard shortcuts

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