JSONPath is a query language for JSON, like XPath is for XML. It provides a way to navigate through and retrieve data from complex JSON structures by specifying the paths to the desired data elements. JSONPath expressions can use either the dot-notation or the bracket-notation for input paths, though internal or output paths will always be converted to the more general bracket-notation. JSONPath allows the use of:
*
for member names and array indices..
[start:end:step]
JSONPath helps retrieve specific data from JSON structures without special scripting. Within SGNL, there are many situations where an upstream client of SGNL will send the service JSON, and there are many times when we want to be selective about the data that we extract from that payload. In that way JSON data can be reduced to parts relevant to SGNL.
SoR Entities Example:
Jira Issues can have associated assets represented as a nested list of JSON objects within the Jira Issues API response. To represent these assets as separate entities in your SGNL graph, you can define a child entity and use JSONPath as the ExternalId to represent the children as new entities:
$.assets[*].id
(This path would extract the ‘id’ of all assets from the ‘assets’ array within the Jira Issue data).By defining the “Asset” entity as a child entity with the specified JSONPath, SGNL will automatically create a “parent” relationship between each “Asset” entity and the “Jira Issue” entity that contains it.
JSONPath in SoR Template YAML Files
SGNL allows for the creation of SoRs using YAML templates.
$.riskFactors
, indicating that the UserRiskFactor data is nested within the ‘riskFactors’ array of the User data.$.accounts[?(@.__typename=="ActiveDirectoryAccountDescriptor")]
.JSONPath in Event Streams Templates
Event Stream Templates make extensive use of JSONPath to retrieve attributes from a Security Event Token
$.jti
$.sub_id.email
JSONPath in Transforms and Provider Hooks
Transorms and Provider Hooks make extensive use of JSONPath to extract mapping values from upstream providers, IdPs, Proxies, and more
{$.data.authenticationContext.resourceServicePrincipal.appId}
for Entra, or {$.data.context.protocol.issuer.id}
for Okta$
and local @
symbols are expanded by a simple regular expression.By understanding these concepts and using the provided examples, you can effectively map attributes from your SoRs into the SGNL platform using JSONPath, enabling powerful data representation and analysis within your SGNL graph.