Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BragdonD/jsonpointer-go

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonpointer-go

License: MIT Build Status codecov

An implementation of RFC 6901 - JavaScript Object Notation (JSON) Pointer in Golang.

Table of Contents

Introduction

jsonpointer-go is a Go library for working with JSON Pointers as defined in RFC 6901. JSON Pointers provide a way to reference specific parts of a JSON document.

Installation

To install the library, simply run:

go get github.com/bragdond/jsonpointer-go

Usage

Here is a simple example of how to use jsonpointer-go:

package main

import (
    "fmt"
    "github.com/bragdond/jsonpointer-go"
)

func main() {   
	jsonStr := `{
        "foo": ["bar", "baz"],
        "qux": {"corge": "grault"}
    }`

    var jsonData map[string]any
    if err := json.Unmarshal([]byte(jsonStr), &jsonData); err != nil {
        panic(fmt.Sprintf("failed to unmarshal json string: %v", err))
    }

    pointer, err := jsonpointer.Parse("/foo/0")
    if err != nil {
        panic(err)
    }

    result, err := pointer.GetValue(jsonData)
    if err != nil {
        panic(err)
    }

    fmt.Println(result) // Output: bar
}

Contributing

We welcome contributions! Please see the CONTRIBUTING.md file for guidelines on how to contribute.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Happy coding!

About

An implementation of RFC 6901 - JavaScript Object Notation (JSON) Pointer in Golang

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Morty Proxy This is a proxified and sanitized view of the page, visit original site.