commit | 02993c407bfbf5f6dae44c4f4b1cf6a39b5fc5bb | [log] [tgz] |
---|---|---|
author | Kévin Dunglas <dunglas@gmail.com> | Wed Sep 04 05:19:12 2019 |
committer | Johan Dorland <johand@a-eskwadraat.nl> | Thu Sep 05 19:47:46 2019 |
tree | 084c2dbba7332e7d94cbcf2f8f7263a427397e2d | |
parent | df4f5c81cb3b310899c091852a576ea7d178aedb [diff] |
Replace link to the I-D to by a link to the RFC
An implementation of JSON Pointer - Go language
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}}`
https://tools.ietf.org/html/rfc6901
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.