Formula - JsonPathKey
Easily extract keys or paths from JSON messages using the Nodinite JsonPathKey
Formula plugin. This page shows how to use regular expressions and JSONPath to retrieve matching keys or paths from message Content, Context, or the output of other formulas.
π― Designed for business users and integrators β no developer required; you can even use AI to craft expressions.
- β Extract keys or paths from any JSON structure from any Payload or Context in any Log Event
- β Flexible pattern matching using regular expressions and JSONPath for precise key selection
- β Transform and surface meaningful data in Nodinite Log Views, search filters, and self-service diagnostics
- β Combine with other Formula functions for powerful, layered expressions
What does the JsonPathKey Formula do?
The JsonPathKey('Expression', Content)
Formula function extracts all keys or paths from a JSON structure that match a given regular expression or JSONPath. You can use this function on message bodies, context values, or results from other formulas.
How it works: Input β JsonPathKey β Result
Flow: The JSON content is analyzed to extract all keys or paths matching the specified expression.
Example
Below is a practical example showing how to extract matching paths from a Swagger JSON API definition.
Input
{"swagger":"2.0","info":{"version":"V1","title":"Nodinite WebAPI","x-swagger-net-version":"8.3.38.001"},"host":"localhost","basePath":"/Nodinite/Dev/WebAPI","schemes":["http"],"paths":{"/api/activedirectorygroups":{"get":{"tags":["ActiveDirectoryGroups"],"summary":"Get a list of Active Directory Groups, limited by specified input","operationId":"ActiveDirectoryGroups_List","consumes":[],"produces":["application/json","text/json"],"parameters":...}}
Formula Expression
JsonPathKey('$.paths.*', body())
Result
/api/activedirectorygroups
/api/activedirectorygroups/{id}
/api/activedirectorygroups/{id}/isnameavailable
...
Example: Extracting matching paths from JSON body using JsonPathKey
Features
The JsonPathKey
Formula function is highly flexible and can be nested with other formula functions. For instance, combine it with concat or replace to manipulate the extracted keys or paths before using them in a Search Field.
- Extract keys or paths using a regular expression or JSONPath from JSON content
- Works with message body, Context, or results from other Formula functions
- Ensures data integrity across integrated systems
Important
The JsonPathKey plugin loads the entire message into RAM. Only use this function on small messages to avoid performance issues.
How to use
The JsonPathKey
formula extracts JSON keys or paths that match your specified regular expression or JSONPath. It's ideal for quickly locating and surfacing specific fields within complex JSON messages.
Syntax
JsonPathKey('Expression', Content)
Parameters:
- Expression (string): A regular expression or JSONPath pattern used to match keys or paths
- Content (string): The JSON message content to search, typically from body() or context()
Example patterns:
'$.paths.*'
β Match all keys under the "paths" object'$..*'
β Match all keys throughout the JSON structure'^/api'
β Match keys starting with "/api"
Extract from different sources:
- Extract from message body:
JsonPathKey('Expression', body())
- Extract from message context:
JsonPathKey('Expression', context('MessageContextKey'))
- Extract from another formula:
JsonPathKey('Expression', jsonPath('$.data', body()))
Next step
- How to Add or manage Search Fields
- How to Add or manage Log Views
Related Topics
- Body β Extract body from the Log Event
- Context β Extract context values from the Log Event
- jsonPath β Extract values from JSON using JSONPath expressions
- regex β Extract data using regular expressions
- Expression Type Plugins are used in Search Fields
- What are Search Fields?
- What are Search Field Expressions?
- What are Message Types?
- What are Log Views?