Skip to content
Documentation
Updated 3 minutes to read
Markdown

The jsonPath Formula function returns the values in JSON content that match a JSONPath expression.

Read the order id from an Order Received event with jsonPath, animated walkthrough (7.12)
Animated walkthrough: jsonPath('$.orderId', body) on the Order Received JSON of the Order-to-Cash demo returns ORD-10005.

jsonPath('expression', content)
Parameter Required Description
'expression' Yes A JSONPath expression in single quotes. The leading $. is optional: 'Seq' and '$.Seq' select the same property.
content Yes The JSON text: body, context, or the result of another function (see Formula language rules).

The value of every node that matches, one value each; duplicates are collapsed. When several content values come in, such as from context(regex(...)), each is parsed and all matches are returned. When nothing matches, nothing is returned.

To return property names instead of values, use jsonPathKey.

{ "Seq": 2 }
jsonPath('Seq', body)
2

Formula jsonPath expression returning the Seq value from a JSON message body in the Test Expression tab (7.12)
'Seq' without $. selects the top-level Seq property.

[
{ "Id": 0 },
{ "Id": 1 },
{ "Id": 1 },
{ "Id": 2 },
{ "Id": 3 }
]
jsonPath('$..Id', body)
0
1
2
3

Formula jsonPath recursive descent returning four unique Id values from a JSON array in the Test Expression tab (7.12)
$..Id (recursive descent) finds every Id at any depth; the duplicate 1 is collapsed, so the test shows four unique matches.

Example 3: Read a property from a context value

Section titled “Example 3: Read a property from a context value”
Key Value
id {"Seq":2}
jsonPath('Seq', context('id'))
2

Formula jsonPath expression reading Seq from the id context property in the Message Context tab (7.12)
The JSON stored in the id context property is parsed like a message body.

Example 4: Read Ids from several context properties

Section titled “Example 4: Read Ids from several context properties”
Key Value
id [{ "Id": 0 },{ "Id": 1 },{ "Id": 1 },{ "Id": 2 }]
id2 [{ "Id": 3 },{ "Id": 4 },{ "Id": 5 },{ "Id":6 }]
jsonPath('$..Id', context(regex('id.*')))
0
1
2
3
4
5
6

Formula jsonPath over two context properties returning seven unique Id values in the Test Expression tab (7.12)
context(regex('id.*')) returns the values of both id and id2; jsonPath parses each and returns seven unique values.

  • Property names in the expression are matched with their exact case: Seq and seq are different properties.
  • A literal ' in a property name is written ''; see Formula language rules.
  • The expression comes first and the content second. jsonPath(body, '$.orderId') is a syntax error (Unexpected String "$.orderId"); write jsonPath('$.orderId', body).
  • A property whose name starts with $, such as the $content of a Logic App request, can be written '$content', '$.$content', or '$[''$content'']'.
  • When one JSONPath on the body or a single context property is all you need, the JSON Path plugin does the same without a formula; use jsonPath to nest, combine, or aggregate. See Choose a plugin.

...

Version:
Release date: N/A
Loading...

Explore Nodinite for 30 days – completely free

  • Find out why this is the leading O&M software
  • Prove your business case
  • Test the self-service for the business side

Loading...

See how Nodinite resolves your technical issues, in a LIVE Demo!

Once you submit this request:

  • We will give you a short call to understand the issues you want to tackle.
  • Understand solutions you have tried and why were you not happy with them.
  • Book a convenient slot for a LIVE demo!

Loading...