---
title: "Formula - jsonPath: Extract Values from JSON"
description: The jsonPath Formula function returns the values in JSON content that match a JSONPath expression. Includes syntax, parameters, and examples from the message body and from one or several context properties.
---

# :fa-function: Formula - jsonPath

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)][31]  
*Animated walkthrough: `jsonPath('$.orderId', body)` on the Order Received JSON of the [Order-to-Cash demo][] returns `ORD-10005`.*  

## :fa-code: Syntax

```text
jsonPath('expression', content)
```

### Parameters

|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][Context], or the result of another function (see [Formula language rules][]).|  

### Returns

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][].

## :fa-list-ol: Examples

### Example 1: Read a property from the body

#### Input

```json
{ "Seq": 2 }
```

#### Formula

```text
jsonPath('Seq', body)
```

#### Result

```text
2
```

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

### Example 2: Read every Id in an array

#### Input

```json
[
{ "Id": 0 },
{ "Id": 1 },
{ "Id": 1 },
{ "Id": 2 },
{ "Id": 3 }
]
```

#### Formula

```text
jsonPath('$..Id', body)
```

#### Result

```text
0
1
2
3
```

![Formula jsonPath recursive descent returning four unique Id values from a JSON array in the Test Expression tab (7.12)][28]  
*`$..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

#### Input

|Key|Value|  
|---|---|  
|id|`{"Seq":2}`|  

#### Formula

```text
jsonPath('Seq', context('id'))
```

#### Result

```text
2
```

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

### Example 4: Read Ids from several context properties

#### Input

|Key|Value|  
|---|---|  
|id|`[{ "Id": 0 },{ "Id": 1 },{ "Id": 1 },{ "Id": 2 }]`|  
|id2|`[{ "Id": 3 },{ "Id": 4 },{ "Id": 5 },{ "Id":6 }]`|  

#### Formula

```text
jsonPath('$..Id', context(regex('id.*')))
```

#### Result

```text
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)][30]  
*`context(regex('id.*'))` returns the values of both `id` and `id2`; `jsonPath` parses each and returns seven unique values.*  

## :fa-circle-info: Notes

* 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][].

## :fa-hand-point-right: Next Steps

* :fa-magnifying-glass-plus: [Add or manage Search Field][]  
* :fa-flask: [Test Your Expression][]  
* :fa-hard-drive: [Add or manage Log View][]  

## :fa-link-horizontal: Related Topics

* :fa-filter: [Extract functions][Extract Group]  
* :fa-file-csv: [csv][]  
* :fa-key: [jsonPathKey][]  
* :fa-text-slash: [regex][]  
* :fa-layer-group: [regexGroup][]  
* :fa-database: [sqllookup][]  
* :fa-code: [xPath][]  
* :fa-code: [xPath2][]  
* :fa-function: [Formula][]  
* :fa-scroll: [Formula language rules][]  
* :fa-puzzle-piece: [Search Field Expressions][]  
* :fa-magnifying-glass: [JSON Path plugin][]  

[27]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Extract/jsonPath_simpleParamter_body.png
[28]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Extract/jsonPath_multipleElements_body.png
[29]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Extract/jsonPath_messageContext.png
[30]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Extract/jsonPath_multipleKeys_messageContext.png
[31]:{ndm}/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Formula_JsonPath.gif

[Add or manage Log View]:{ndr}/Administration/1.%20Log%20Management/1.%20Log%20Views/Features/Add%20or%20Manage%20Log%20View.md
[Add or manage Search Field]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md
[body]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/body.md
[Choose a plugin]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md#fa-signs-post-choose-a-plugin
[Context]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Source/context.md
[csv]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/csv.md
[Extract Group]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md#extract
[Formula]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md
[Formula language rules]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Overview.md#fa-scroll-formula-language-rules
[JSON Path plugin]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/JSON%20Path.md
[jsonPathKey]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/JsonPathKey.md
[Order-to-Cash demo]:{ndr}/Repository%20Model/BPMs/Examples/Order-to-Cash/Generate-O2C-Demo-Data.md
[regex]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/regex.md
[regexGroup]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/regexGroup.md
[Search Field Expressions]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Overview.md
[sqllookup]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/sqllookup.md
[Test Your Expression]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Add%20or%20manage%20Search%20Field.md#test-your-expression
[xPath]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/xPath.md
[xPath2]:{ndr}/Administration/1.%20Log%20Management/2.%20Search%20Fields/Features/Search%20Field%20Expressions/Formula/Extract/xPath2.md