DockerCLI/vendor/github.com/xeipuuv/gojsonpointer
Sebastiaan van Stijn 7b8c6a6325
bump github.com/xeipuuv/gojsonpointer 02993c407bfbf5f6dae44c4f4b1cf6a39b5fc5bb
full diff: 4e3ac2762d...02993c407b

only a gofmt and documentation change

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-11 00:30:57 +02:00
..
LICENSE-APACHE-2.0.txt Add vendor 2017-04-17 18:12:58 -04:00
README.md bump github.com/xeipuuv/gojsonpointer 02993c407bfbf5f6dae44c4f4b1cf6a39b5fc5bb 2019-10-11 00:30:57 +02:00
pointer.go bump github.com/xeipuuv/gojsonpointer 02993c407bfbf5f6dae44c4f4b1cf6a39b5fc5bb 2019-10-11 00:30:57 +02:00

README.md

gojsonpointer

An implementation of JSON Pointer - Go language

Usage

jsonText := `{
	"name": "Bobby B",
	"occupation": {
		"title" : "King",
		"years" : 15,
		"heir" : "Joffrey B"			
	}
}`

var jsonDocument map[string]interface{}
json.Unmarshal([]byte(jsonText), &jsonDocument)

//create a JSON pointer
pointerString := "/occupation/title"
pointer, _ := NewJsonPointer(pointerString)

//SET a new value for the "title" in the document     
pointer.Set(jsonDocument, "Supreme Leader of Westeros")

//GET the new "title" from the document
title, _, _ := pointer.Get(jsonDocument)
fmt.Println(title) //outputs "Supreme Leader of Westeros"

//DELETE the "heir" from the document
deletePointer := NewJsonPointer("/occupation/heir")
deletePointer.Delete(jsonDocument)

b, _ := json.Marshal(jsonDocument)
fmt.Println(string(b))
//outputs `{"name":"Bobby B","occupation":{"title":"Supreme Leader of Westeros","years":15}}`

References

https://tools.ietf.org/html/rfc6901

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.