summaryrefslogtreecommitdiff
path: root/vendor/github.com/xeipuuv/gojsonpointer/README.md
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-01-08 14:52:57 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-01-11 13:38:11 +0100
commitbd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87 (patch)
tree5f06e4e289f16d9164d692590a3fe6541b5384cf /vendor/github.com/xeipuuv/gojsonpointer/README.md
parent545f24421247c9f6251a634764db3f8f8070a812 (diff)
downloadpodman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.tar.gz
podman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.tar.bz2
podman-bd40dcfc2bc7c9014ea1f33482fb63aacbcdfe87.zip
vendor: update everything
* If possible, update each dependency to the latest available version. * Use releases over commit IDs and avoid vendoring branches. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/xeipuuv/gojsonpointer/README.md')
-rw-r--r--vendor/github.com/xeipuuv/gojsonpointer/README.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/github.com/xeipuuv/gojsonpointer/README.md b/vendor/github.com/xeipuuv/gojsonpointer/README.md
index dbe4d5082..00059242c 100644
--- a/vendor/github.com/xeipuuv/gojsonpointer/README.md
+++ b/vendor/github.com/xeipuuv/gojsonpointer/README.md
@@ -1,6 +1,39 @@
# 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
http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-07