Free cookie consent management tool by TermsFeed

a!jsonPath() Function

On This Page

a!jsonPath( value, expression )

Finds information in a JSON string. JSONPath is used to navigate through elements and attributes in a JSON string.

Parameters

Keyword Type Description

value

Text

The JSON text representing the value to be queried.

expression

Text

The JSONPath query to be run against the JSON object.

Returns

Text

Using the function

Using the expression parameter

The a!jsonPath() function uses JSONPath syntax in the expression parameter to navigate JSON structures. The following table defines the supported JSONPath operators:

Expression Description
$ The root object or element.
@ The current object or element.
. or [] Child operator. Accesses a specific child element by name or index.
.. Recursive descent. Searches for a key at any depth in the JSON structure.
* Wildcard. Returns all objects or elements regardless of their names.
[] Subscript operator. Accesses a specific array element by index.
[,] Alternate names or array indices as a set. Returns multiple elements.
[start:end:step] Array slice operator. Returns a range of elements from an array.
?() Filter expression. Applies a filter condition to select matching elements.
() Script expression. Evaluates using the underlying script engine.

Note:  Array indices in JSONPath start with zero, not one.

Examples

The following examples demonstrate the a!jsonPath() function.

To experiment with examples, copy and paste the expression into an expression rule and click TEST RULE to see the output.

Root object operator ($)

The a!jsonPath() root operator ($) returns the entire JSON object:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$"
  )
)

Child operators

The a!jsonPath() child operators (. or []) accesses a specific child element by name or index.

Child operator using dot notation (.)

The following example returns the store name using dot notation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$.store.name"
  )
)

Returns: "My Bookstore"

Child operator using bracket notation ([])

The following example returns the first book using bracket notation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$.store.books[0]"
  )
)

Returns: {"author":"F. Scott Fitzgerald","price":10.99,"title":"The Great Gatsby"}

Recursive descent operator (..)

The a!jsonPath() recursive descent operator (..) searches for a key at any depth in the JSON structure. The following example returns all prices regardless of their location:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$..price"
  )
)

Returns: [10.99,7.99,8.99]

Wildcard operator (*)

The a!jsonPath() wildcard operator (*) returns all elements in an object or array. The following example returns all books in the array:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$.store.books[*]"
  )
)

Subscript operator ([])

The a!jsonPath() subscript operator ([]) accesses a specific array element by index. The following example returns the second book (index 1):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$.store.books[1]"
  )
)

Returns: {"author":"Harper Lee","price":7.99,"title":"To Kill a Mockingbird"}

Alternate indices operator ([,])

The a!jsonPath() alternate indices operator ([,]) returns multiple elements by specifying several indices. The following example returns the first and third books:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$.store.books[0,2]"
  )
)

Returns: [{"author":"F. Scott Fitzgerald","price":10.99,"title":"The Great Gatsby"},{"author":"George Orwell","price":8.99,"title":"1984"}]

Array slice operator ([start:end:step])

The a!jsonPath() array slice operator ([start:end:step]) returns a range of elements from an array. The following example returns the first two books:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$.store.books[0:2]"
  )
)

Returns: [{"author":"F. Scott Fitzgerald","price":10.99,"title":"The Great Gatsby"},{"author":"Harper Lee","price":7.99,"title":"To Kill a Mockingbird"}]

Filter expression operator (?())

The a!jsonPath() filter expression operator (?()) filters elements based on a condition. The following example returns books with a price less than 9.00:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$.store.books[?(@.price < 9.00)]"
  )
)

Returns: [{"author":"Harper Lee","price":7.99,"title":"To Kill a Mockingbird"},{"author":"George Orwell","price":8.99,"title":"1984"}]

Current object operator(@)

The a!jsonPath() current object operator (@) references the current element within a filter or expression. The following example returns titles of books where the author is "George Orwell":

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
a!localVariables(
  local!json: "{
    ""store"": {
      ""name"": ""My Bookstore"",
      ""books"": [
        {
          ""title"": ""The Great Gatsby"",
          ""author"": ""F. Scott Fitzgerald"",
          ""price"": 10.99
        },
        {
          ""title"": ""To Kill a Mockingbird"",
          ""author"": ""Harper Lee"",
          ""price"": 7.99
        },
        {
          ""title"": ""1984"",
          ""author"": ""George Orwell"",
          ""price"": 8.99
        }
      ]
    }
  }",
  a!jsonPath(
    value: local!json,
    expression: "$.store.books[?(@.author == 'George Orwell')].title"
  )
)

Returns: ["1984"]

Feature compatibility

The table below lists this function's compatibility with various features in Appian.
Feature Compatibility Note
Portals Partially compatible

Can be used with Appian Portals if it is connected using an integration and web API.

Offline Interfaces Incompatible
Sync-Time Custom Record Fields Incompatible
Real-Time Custom Record Fields Incompatible

Custom record fields that evaluate in real time must be configured using one or more Custom Field functions.

Process Reports Incompatible

Cannot be used to configure a process report.

Process Events Partially compatible

If autoscale is enabled, can be used to configure a supported process event node (such as a start event or timer event).

Process Autoscaling Compatible

Can be used in autoscaled processes.

Event Consumer Filter Conditions Incompatible

Cannot be used in filter conditions.

Event Consumer Event Handlers Incompatible

Cannot be used in event handler expressions.

Feedback