jsonpath

package module
v0.0.0-...-763e66d Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 11 Imported by: 0

README

#jsonpath

  • requirement:
    • golang 1.9
  • operators: TODO

supported syntax:

  • / $ the root object/element
  • . @ the current object/element
  • / . or [] child operator
  • // .. recursive descent. JSONPath borrows this syntax from E4X.
    • * 	wildcard. All objects/elements regardless their names.
      
  • [] [] subscript operator. XPath uses it to iterate over element collections and for predicates. In Javascript and JSON it is the native array operator.
  • | [,] Union operator in XPath results in a combination of node sets. JSONPath allows alternate names or array indices as a set.
  • n/a [start🔚step] array slice operator borrowed from ES4.
  • [] ?() applies a filter (script) expression. unsupported syntax: n/a () script expression, using the underlying script engine.

filter script expression only supports finit expression like: @aaa op other @.number >= $.number // means filters the current node which number greater than root number

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JsonPath

type JsonPath struct {
	Data interface{}
}

necessary to decide whether log jsonpath problems; JsonPath is exported

func (*JsonPath) Find

func (jp *JsonPath) Find(expr string) *Result

Find json's value and return JsonResult

func (*JsonPath) SetValue

func (jp *JsonPath) SetValue(expr string, v interface{}) (bool, error)

SetValue sets json's value and return bool,err

func (*JsonPath) UnsetValue

func (jp *JsonPath) UnsetValue(expr string) (bool, error)

UnsetValue unsets json's value and return bool,err

type Result

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

Result represents return value

func (*Result) All

func (jpr *Result) All() ([]interface{}, bool, error)

All returns collection

func (*Result) FilterFloat64

func (jpr *Result) FilterFloat64() ([]float64, bool, error)

func (*Result) FilterString

func (jpr *Result) FilterString() ([]string, bool, error)

func (*Result) First

func (jpr *Result) First() (interface{}, bool, error)

First returns the first element of result collection

Directories

Path Synopsis
test command

Jump to

Keyboard shortcuts

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