JSONPath

Introduction

All data within contexts is accessed using JSONPath. Conigma Connect uses the JsonPath.Net library for resolving these paths, and this functionality is directly available to the user in the flow editor. While the Flow Tutorial shows simple, direct paths for demonstration purposes, JSONPath also provides advanced querying features such as filters, wildcards, conditional matching and array indexing for navigating and extracting data from complex JSON structures. This page outlines specific, practical aspects of JSONPath relevant to working with flows in Conigma Connect.

The examples are built towards the following example JSON object:

Rendering...

Property Access

Dot Notation

$.customer.name

Dot notation is the simplest way to access properties with valid JSON names. Above example selects the name property from the customer object at the root level.

Result: Alice

Bracket Notation

$['customer']['maxPrice']

Bracket notation is required when property names contain spaces, dots, or special characters.

Result: 500

Arrays and Recursive Access

Index

$.customer.orders[0].status

Selects the status of the first order.

Result: shipped

$.customer.orders[-1].status

Selects the status of the last order.

Result: shipped

Slice

$.customer.orders[0:2]

Selects a range of array elements.

Result:

Wildcard

$.customer.orders[*].status

Selects the status of every order.

Result: ["shipped", "processing", "cancelled", "shipped"]

Multiple Properties

$.customer.orders[*]['status','orderId']

Selects both status and orderId values from every order item.

Result: ["shipped","O-501","processing","O-502","cancelled","O-503","shipped","O-504"]

Recursive Descent

$..sku

Searches for the property sku at any depth.

Result: ["A100", "B200", "C300", ...]

Filters

Local Scope (@)

$.customer.orders[?(@.status == 'shipped')].orderId

Returns order IDs where the local status equals "shipped".

Result: ["O-501", "O-504"]

Global Scope ($)

$.customer.orders[?(@.items[0].price < $.customer.maxPrice)].orderId

Filters by comparing values to another part of the document.

Result: ["O-502", "O-503", "O-504"]

length()

$.customer.orders[?(length(@.items) > 1)].orderId

Returns orders containing more than one item.

Result: ["O-501", "O-502", "O-504"]

count()

$.customer.orders[?(count(@.items[*]) == 1)].orderId

count() returns the number of JSON nodes in the selected node set. In this case all orderIds are selected where the order has only one item.

Result: ["O-503"]

The JSONPath does not process an array’s length unless you first expand the array into its element nodes using the wildcard [*]!

Correct: count(@.items[*]) == 1 // counts element nodes

Incorrect: count(@.items) == 1 // counts the single array node itself

match()

$.customer.orders[?(match(@.status, 'shipped'))].orderId

Checks for exact regex matches.

Result: ["O-501", "O-504"]

$.customer.orders[*].items[?(search(@.name, 'top'))].sku

Checks for any substring regex matches.

Result: ["A100"]

Overview Table

Note: The contents of the table are just abstract examples and do not refer to the example JSON above.

Feature

Example Path

Description

Root element

$.store

Accesses a property at the root

Property (dot)

$.store.id

Gets a child property by name

Property (dot)

$['store']['maxPrice']

Gets a child property using bracket syntax

Array index

$.items[0]

Selects the first element in an array

Array index

$.items[-1]

Selects the last element in an array

Slice

$.items[0:2]

Selects a range of array elements

Wildcard

$.items[*].name

Selects properties of all elements

Multiple Properties

$.items[*]['name','price']

Selects both name and price as a flat list

Recursive descent

$..id

Searches for a property at any depth

Local @

$.items[?(@.price < 100)]

Filters array elements by condition on the element itself

Global $

$.items[?(@.value == $.limit)]

Filters using values from elsewhere

length()

$.items[?(length(@.tags) > 2)]

Filters by length of an array property

count()

$.items[?(count(@.tags[*]) == 1)]

Filters by number of nodes

match()

$.items[?(match(@.state,'ok'))

Filters by exact regex match

search()

$.items[?(search(@.name,'a'))]

Filters by substring regex search