lookup

package module
v0.0.0-...-1bc6d3c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2015 License: MIT Imports: 8 Imported by: 0

README

lookup

This package provides a way to search and manipulate JSON files using simple JSON path expressions.

Utilities

A utility named loookup is included, that can be used for finding a value in a JSON document when given a simple JSON path expression.

You can do things like x.store.book[0].title.

x is the root node.

This is a spartan implementation of JSON paths. Only . and [ ] are supported so far.

Documentation

Overview

Package lookup provides a way to search and manipulate JSON files using simple JSON path expressions

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSpecificNode = errors.New("Could not find a specific node that matched the given path")
)

Functions

func JSONAdd

func JSONAdd(filename, JSONpath, JSONdata string) error

func JSONSet

func JSONSet(filename, JSONpath, value string) error

func JSONString

func JSONString(filename, JSONpath string) (string, error)

JSONString will find the string that corresponds to the given JSON Path, given a filename and a simple JSON path expression.

Types

type JSONFile

type JSONFile struct {
	// contains filtered or unexported fields
}

JSONFile represents a JSON file and contains the filename and root node

func NewJSONFile

func NewJSONFile(filename string) (*JSONFile, error)

NewJSONFile will read the given filename and return a JSONFile struct

func (*JSONFile) AddJSON

func (jf *JSONFile) AddJSON(JSONpath, JSONdata string) error

func (*JSONFile) Lookup

func (jf *JSONFile) Lookup(JSONpath string) (*simplejson.Json, error)

Lookup will find the JSON node that corresponds to the given JSON path

func (*JSONFile) LookupString

func (jf *JSONFile) LookupString(JSONpath string) (string, error)

LookupString will find the string that corresponds to the given JSON Path

func (*JSONFile) SetString

func (jf *JSONFile) SetString(JSONpath, value string) error

func (*JSONFile) Write

func (jf *JSONFile) Write(data []byte) error

Directories

Path Synopsis
utils
add

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL