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

# <i class="fal fa-function" aria-hidden="true"></i> 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`.*  

## <i class="fal fa-code" aria-hidden="true"></i> 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][].

## <i class="fal fa-list-ol" aria-hidden="true"></i> 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.*  

## <i class="fal fa-circle-info" aria-hidden="true"></i> 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][].

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

* <i class="fal fa-magnifying-glass-plus" aria-hidden="true"></i> [Add or manage Search Field][]  
* <i class="fal fa-flask" aria-hidden="true"></i> [Test Your Expression][]  
* <i class="fal fa-hard-drive" aria-hidden="true"></i> [Add or manage Log View][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

* <i class="fal fa-filter" aria-hidden="true"></i> [Extract functions][Extract Group]  
* <i class="fal fa-file-csv" aria-hidden="true"></i> [csv][]  
* <i class="fal fa-key" aria-hidden="true"></i> [jsonPathKey][]  
* <i class="fal fa-text-slash" aria-hidden="true"></i> [regex][]  
* <i class="fal fa-layer-group" aria-hidden="true"></i> [regexGroup][]  
* <i class="fal fa-database" aria-hidden="true"></i> [sqllookup][]  
* <i class="fal fa-code" aria-hidden="true"></i> [xPath][]  
* <i class="fal fa-code" aria-hidden="true"></i> [xPath2][]  
* <i class="fal fa-function" aria-hidden="true"></i> [Formula][]  
* <i class="fal fa-scroll" aria-hidden="true"></i> [Formula language rules][]  
* <i class="fal fa-puzzle-piece" aria-hidden="true"></i> [Search Field Expressions][]  
* <i class="fal fa-magnifying-glass" aria-hidden="true"></i> [JSON Path plugin][]  

[27]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Extract/jsonPath_simpleParamter_body.png
[28]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Extract/jsonPath_multipleElements_body.png
[29]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Extract/jsonPath_messageContext.png
[30]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Extract/jsonPath_multipleKeys_messageContext.png
[31]:https://docs.nodinite.com/media/Documentation%20Pictures/IM/WebClient/Admin/Log/Search%20Fields/Plugins/Formula/Formula_JsonPath.gif

[Add or manage Log View]:https://docs.nodinite.com/administration/log-management/log-views/features/add-or-manage-log-view/
[Add or manage Search Field]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/
[body]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/source/body/
[Choose a plugin]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/#fa-signs-post-choose-a-plugin
[Context]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/source/context/
[csv]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/csv/
[Extract Group]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/#extract
[Formula]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/
[Formula language rules]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/overview/#fa-scroll-formula-language-rules
[JSON Path plugin]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/json-path/
[jsonPathKey]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/jsonpathkey/
[Order-to-Cash demo]:https://docs.nodinite.com/repository-model/bpms/examples/order-to-cash/generate-o2c-demo-data/
[regex]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/regex/
[regexGroup]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/regexgroup/
[Search Field Expressions]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/overview/
[sqllookup]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/sqllookup/
[Test Your Expression]:https://docs.nodinite.com/administration/log-management/search-fields/features/add-or-manage-search-field/#test-your-expression
[xPath]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/xpath/
[xPath2]:https://docs.nodinite.com/administration/log-management/search-fields/features/search-field-expressions/formula/extract/xpath2/