Skip to content

json-validate/json-pointer-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

json-pointer documentation

This library is a Golang implementation of RFC6901 "JavaScript Object Notation (JSON) Pointer".

Usage

This library does not perform JSON encoding/decoding. Instead, you must provide data in the default Golang format for JSON data, namely:

bool, for JSON booleans
float64, for JSON numbers
string, for JSON strings
[]interface{}, for JSON arrays
map[string]interface{}, for JSON objects
nil for JSON null

(from the docs for encoding/json#Unmarshal)

To create a JSON Pointer, use New. To evaluate a pointer, use Eval:

ptr, err := jsonpointer.New("/foo/1/bar")

data := map[string]interface{}{
  "foo": []interface{}{
    nil,
    map[string]interface{}{
      "bar": "hello, world",
    },
  },
}

val, err := ptr.Eval(&data)
fmt.Println(val) // outputs "hello, world"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages