JSONPath mappings for Generic REST API connector
Learn how to effectively use JsonPath mappings to streamline data extraction in a Generic REST API connector for enhanced integration.
JSONPath mappings for Generic REST API connector
Learn how to effectively use JsonPath mappings to streamline data extraction in a Generic REST API connector for enhanced integration.
Generic REST API Connector allows to configure attribute mappings using JSONPath language.
Following table shows supported and not supported JSONPath syntaxes. Because there are so many possible JSONPath expressions, this table doesn't contain everything. So something outside of supported ones probably also works.
Main unsupported thing is that if JSONPath returns an array of JSON objects, that is not supported.
JSONPath mappings were tested agains this example json:
{
"id": "u-123",
"user": {
"name": "Ada Lovelace",
"email": "ada@example.com",
"first-name": "Ada",
"meta": {
"active": true,
"score": 42,
"nullField": null
}
},
"store": {
"book": "abc",
"bike": "xyz",
"nested": {
"price": 9.99,
"currency": "EUR"
}
},
"groups": ["Admin", "HR"],
"groupObjects": [
{ "name": "Admin", "id": 1, "enabled": true },
{ "name": "HR", "id": 2, "enabled": false }
],
"child": {
"id": "child-1",
"child": {
"id": "child-2"
}
},
"storeList": [
{ "id": "s1", "name": "Shop 1", "price": 10 },
{ "id": "s2", "name": "Shop 2", "price": 20 }
],
"emptyArray": [],
"emptyObject": {},
"weirdKeys": {
"a.b": "dot-key",
"space key": "space-key",
"brackets[key]": "bracket-key"
}
}Supported and not supported JSONPath syntaxes
| Standard JSONPath | Syntax used in Connector mapping table | Example Result | Notes | Status |
|---|---|---|---|---|
$.id |
id |
"u-123" |
Simple scalar property | Supported |
$.user.name |
user.name |
"Ada Lovelace" |
Nested property | Supported |
$.user.email |
user.email |
"ada@example.com" |
Nested property | Supported |
$.user['first-name'] |
user['first-name'] |
"Ada" |
Bracket notation works | Supported |
$.user.meta.active |
user.meta.active |
true |
Boolean value | Supported |
$.user.meta.score |
user.meta.score |
42 |
Multiple nested property. Number value (map to string or number) | Supported |
$.store.nested.price |
store.nested.price |
9.99 |
Multiple nested property. Decimal value (map to string or decimal number) | Supported |
$.groups |
groups |
["Admin","HR"] |
Array of strings (map to multivalue string attribute) | Supported |
$.groupObjects[*].name |
groupObjects[*].name |
["Admin","HR"] |
Projection to array of strings (map to multivalue string attribute) | Supported |
$.storeList[?(@.id=='s1')].price |
storeList[?(@.id=='s1')].price |
[10] |
String filter without spaces | Supported |
$.storeList[?(@.price<30)].id |
storeList[?(@.price<30)].id |
["s1","s2"] |
Numeric filter (map to multivalue string attribute) Also other comparison operators are supported like: == <= >= > < != |
Supported |
$.groupObjects[?(@.enabled==false)].name |
groupObjects[?(@.enabled==false)].name |
["HR"] |
Boolean filter (map to multivalue string attribute) |
Supported |
$.groupObjects |
groupObjects |
[{"name":"Admin",...},{"name":"HR",...}] |
Returns array of JSON objects | Not Supported |
$.groupObjects[*] |
groupObjects[*] |
[{"name":"Admin",...},{"name":"HR",...}] |
Projection returns array of JSON objects | Not Supported |
$.storeList[?(@.price<30)] |
storeList[?(@.price<30)] |
[{"id":"s1",...},{"id":"s2",...}] |
Filter returns array of JSON objects | Not Supported |
$.storeList[?(@.name=='Shop 1')].price |
storeList[?(@.name=='Shop 1')].price |
[10] |
String filter literal containing space fails | Not Supported |
$..id |
..id |
[ "u-123", "child-1", "child-2", ... ] |
Recursive descent | Not Supported |
$.store.* |
store.* |
["abc","xyz",{...}] |
Object wildcard | Not Supported |
Subquery mappings
Subquery mappings first part is subquery itself, then dot and then actual JSONPath same way than in supported JSONPath syntaxes table.
Example for fetching users group memberships from Google
Subquery: groups?userKey={id}
In subquery {id} is dynamic variable, which in this case points to main query resultset id attribute. JSONPath is not supported on subqueries.
Mapping for that subquery, to fetch id's of groups which one user belongs:
groups?userKey={id}.groups[*].id where actual JSONPath is this part on the end: groups[*].id
Example of Google groups API json. With subquery and mapping we can pick id's of groups from this resultset.
{ "kind": "directory#groups", "etag": "\"p7cdf8ab12e9\"", "groups": [ { "kind": "directory#group", "id": "01abcde123456789", "etag": "\"abc123etag\"", "email": "engineering@efectebaselinedev.onmicrosoft.com", "name": "Engineering Team", "description": "Main engineering group", "directMembersCount": "15", "adminCreated": true, "aliases": [ "eng@efectebaselinedev.onmicrosoft.com" ], "nonEditableAliases": [ "engineering@group.calendar.google.com" ] }, { "kind": "directory#group", "id": "02xyz987654321", "etag": "\"xyz456etag\"", "email": "support@efectebaselinedev.onmicrosoft.com", "name": "Support", "description": "Customer support group", "directMembersCount": "8", "adminCreated": true } ], "nextPageToken": "CgYIARAA"}
Table of Contents