Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattn/go-jsonpointer
https://github.com/mattn/go-jsonpointer
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mattn/go-jsonpointer
- Owner: mattn
- License: mit
- Created: 2014-10-30T01:15:23.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2019-11-28T15:47:22.000Z (almost 5 years ago)
- Last Synced: 2024-10-23T08:53:15.270Z (22 days ago)
- Language: Go
- Size: 16.6 KB
- Stars: 97
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-jsonpointer
[![Build Status](https://travis-ci.org/mattn/go-jsonpointer.png?branch=master)](https://travis-ci.org/mattn/go-jsonpointer)
[![Codecov](https://codecov.io/gh/mattn/go-jsonpointer/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-jsonpointer)
[![GoDoc](https://godoc.org/github.com/mattn/go-jsonpointer?status.svg)](http://godoc.org/github.com/mattn/go-jsonpointer)
[![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-jsonpointer)](https://goreportcard.com/report/github.com/mattn/go-jsonpointer)Go implementation of JSON Pointer (RFC6901)
## Usage
`jsonpointer.Get(obj, pointer)`
```go
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)`
```go
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)`
```go
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)