The extract_fields_by_path adapter pulls a value from one part of the response (often a metadata or headers section) and inserts it as a new field on each row in another part. Useful when a value such as a currency code appears once in the response but you want it available on every data row.
| Field | Type | Default | Required | Description |
|---|---|---|---|---|
dataPath |
string | $ |
Yes | JSONPath to the rows that should receive the extracted field. |
sourcePath |
string | $ |
Yes | JSONPath to the source items that hold the value to extract. |
keyPath |
string | $ |
Yes | JSONPath, relative to each source item, identifying the name of the new field. |
valuePath |
string | $ |
Yes | JSONPath, relative to each source item, identifying the value to extract. |
fieldPath |
string | $ |
No | JSONPath structure under which the extracted value is wrapped on each row (for example, $.value produces { "value": ... }). When left at the default, the extracted value is inserted as a plain key-value pair. |
suffix |
string | '' |
No | Suffix appended to the new field's name (for example, _CURRENCY). |
Below you can find a before/after example. The original response keeps the currency code only in headers:
{
"headers": [
{
"name": "ESTIMATED_EARNINGS",
"currencyCode": "EUR"
},
{
"name": "CLICKS"
}
],
"rows": [
{
"ESTIMATED_EARNINGS": {
"value": "200"
},
"CLICKS": {
"value": "5"
}
}
]
}
After the adapter runs, every row carries the currency code as a new field on the matching metric:
{
"rows": [
{
"ESTIMATED_EARNINGS": {
"value": "200"
},
"CLICKS": {
"value": "5"
},
"ESTIMATED_EARNINGS_CURRENCY": {
"value": "EUR"
}
}
]
}
Configuration:
"response": {
"dataRows": {
"source": "jsonPath",
"value": "$.rows.*"
},
"dataAdapters": {
"items": [
{
"type": "extract_fields_by_path",
"config": {
"dataPath": "$.rows.*",
"sourcePath": "$.headers.*",
"keyPath": "$.name",
"valuePath": "$.currencyCode",
"fieldPath": "$.value",
"suffix": "_CURRENCY"
}
}
]
}
}
Below you can find example field definitions that read from the transformed structure:
[
{
"id": "estimated_earnings",
"label": "Estimated earnings",
"dataType": "float.currency.value",
"value": {
"source": "jsonPath",
"value": "$.ESTIMATED_EARNINGS.value"
}
},
{
"id": "clicks",
"label": "Clicks",
"dataType": "int.number.value",
"value": {
"source": "jsonPath",
"value": "$.CLICKS.value"
}
},
{
"id": "currency_code",
"label": "Currency code",
"dataType": "string.currency.code",
"value": {
"source": "jsonPath",
"value": "$.ESTIMATED_EARNINGS_CURRENCY.value"
}
}
]