jsonpath

package
v0.0.0-...-fa720cf Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Current = "__current__"

Current represents the 'current' traveler namespace

Functions

func GetDoc

func GetDoc(traveler gdbi.Traveler, namespace string) map[string]interface{}

GetDoc returns the document referenced by the provided namespace.

Example for a traveler containing:

{
    "current": {...},
    "marks": {
      "gene": {
        "gid": 1,
        "label": "gene",
        "data": {
          "symbol": {
            "ensembl": "ENSG00000012048",
            "hgnc": 1100,
            "entrez": 672
          }
        }
      }
    }
  }
}

GetDoc(traveler, "gene") returns:

{
  "gid": 1,
  "label": "gene",
  "data": {
    "symbol": {
      "ensembl": "ENSG00000012048",
      "hgnc": 1100,
      "entrez": 672
    }
  }
}

func GetJSONPath

func GetJSONPath(path string) string

GetJSONPath strips the namespace from the path and returns the valid Json path within the document referenced by the namespace

Example: GetJSONPath("gene.symbol.ensembl") returns "$.data.symbol.ensembl"

func GetNamespace

func GetNamespace(path string) string

GetNamespace returns the namespace of the provided path

Example: GetNamespace("$gene.symbol.ensembl") returns "gene"

func RenderTraveler

func RenderTraveler(traveler gdbi.Traveler, template interface{}) interface{}

RenderTraveler takes a template and fills in the values using the data structure

func SelectTravelerFields

func SelectTravelerFields(t gdbi.Traveler, keys ...string) gdbi.Traveler

SelectTravelerFields returns a new copy of the traveler with only the selected fields

func TravelerPathExists

func TravelerPathExists(traveler gdbi.Traveler, path string) bool

TravelerPathExists returns true if the field exists in the given Traveler

func TravelerPathLookup

func TravelerPathLookup(traveler gdbi.Traveler, path string) interface{}

TravelerPathLookup gets the value of a field in the given Traveler

Example for a traveler containing:

{
    "current": {...},
    "marks": {
      "gene": {
        "gid": 1,
        "label": "gene",
        "data": {
          "symbol": {
            "ensembl": "ENSG00000012048",
            "hgnc": 1100,
            "entrez": 672
          }
        }
      }
    }
  }
}

TravelerPathLookup(travler, "$gene.symbol.ensembl") returns "ENSG00000012048"

func TravelerSetValue

func TravelerSetValue(traveler gdbi.Traveler, path string, val interface{}) error

TravelerSetValue(travler, "$gene.symbol.ensembl", "hi") inserts the value in the location"

Types

This section is empty.

Jump to

Keyboard shortcuts

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