Skip to main content
Version: 7.9

jsonGet

New in 7.9.2

This function is used by Ignition's Expression language.

Description

Takes a JSON friendly string and a path string, and returns the value of that path.

Syntax

jsonGet(json, path)

  • Parameters

    • string json - The JSON string. The string must be in a JSON-friendly format.

      //The json parameter must be wrapped in {}, and contain a colon between the key and the value.
      //Since the parameter passed is a string datatype, the whole parameter must be wrapped in quotes.
      "{key:value}"

      //You may optionally wrap strings in quotation marks.
      "{'key':'value'}"

      //You may also nest objects inside of the value, much like you can do with Python dictionaries.
      "{keyCollection1:{firstKey:value1, secondKey:value2}, keyCollection2:{firstKey:value1, secondKey:value2}}"
    • string path - The path to look for in the JSON string.

  • Results

    • object - The value at the path.

Examples

Code Snippet
// This example takes a JSON friendly string and finds the value located at the path item.secondThing, which is 2.

jsonGet("{'item':{'firstThing':1, 'secondThing':2}}", "item.secondThing")
Code Snippet
// This example takes a JSON friendly string and finds the value located at the path item, which is {"firstThing":1,"secondThing":2}.

jsonGet("{'item':{'firstThing':1, 'secondThing':2}}", "item")