Documentation Index

Fetch the complete documentation index at: https://docs.supermetrics.com/llms.txt

Use this file to discover all available pages before exploring further.

Split to rows

Prev Next

The split_to_rows adapter splits a delimited string at dataPath into multiple objects, one per token. The original value is replaced with the array of new objects, each carrying the token under keyName.

Field Type Required Description
dataPath string Yes JSONPath to the string value to split.
separator string Yes The character (or substring) used to split the value.
keyName string Yes The name of the field that holds each split token on the resulting objects.

Below you can find a before/after example:

{
  "result": {
    "someProperty": "foo",
    "theImportantProperty": "123123,456456,789789"
  }
}

After the adapter runs, the comma-separated string becomes an array of objects:

{
  "result": {
    "someProperty": "foo",
    "theImportantProperty": [
      {
        "someNewPropKey": "123123"
      },
      {
        "someNewPropKey": "456456"
      },
      {
        "someNewPropKey": "789789"
      }
    ]
  }
}

Configuration:

"response": {
  "dataRows": {
    "source": "jsonPath",
    "value": "$.result.theImportantProperty.*"
  },
  "dataAdapters": {
    "items": [
      {
        "type": "split_to_rows",
        "config": {
          "dataPath": "$.result.theImportantProperty",
          "separator": ",",
          "keyName": "someNewPropKey"
        }
      }
    ]
  }
}

Below you can find example field definitions that read from the transformed structure:

[
  {
    "id": "value",
    "label": "Value",
    "dataType": "string.text.value",
    "value": {
      "source": "jsonPath",
      "value": "$.someNewPropKey"
    }
  }
]

Combining with flatten_values

With split_to_rows alone, each row holds only the value from the split array — the parent-level fields (such as someProperty) cannot be accessed easily on those rows. If your report needs fields from both the parent level and the split-out values, chain split_to_rows with the Flatten values adapter so each split-out value becomes its own row that also carries the parent's other fields. The per-split key is prefixed with the source array's name (for example theImportantProperty_someNewPropKey).

After both adapters run, the result becomes an array where each entry contains both the parent-level fields and one split-out value:

{
  "result": [
    {
      "someProperty": "foo",
      "theImportantProperty_someNewPropKey": "123123"
    },
    {
      "someProperty": "foo",
      "theImportantProperty_someNewPropKey": "456456"
    },
    {
      "someProperty": "foo",
      "theImportantProperty_someNewPropKey": "789789"
    }
  ]
}

Configuration:

"response": {
  "dataRows": {
    "source": "jsonPath",
    "value": "$.result.*"
  },
  "dataAdapters": {
    "items": [
      {
        "type": "split_to_rows",
        "config": {
          "dataPath": "$.result.theImportantProperty",
          "separator": ",",
          "keyName": "someNewPropKey"
        }
      },
      {
        "type": "flatten_values",
        "config": {
          "dataPath": "$.result",
          "valuesPath": "$.theImportantProperty.*"
        }
      }
    ]
  }
}

Below you can find example field definitions that read from the transformed structure:

[
  {
    "id": "some_property",
    "label": "Some property",
    "dataType": "string.text.value",
    "value": {
      "source": "jsonPath",
      "value": "$.someProperty"
    }
  },
  {
    "id": "value",
    "label": "Value",
    "dataType": "string.text.value",
    "value": {
      "source": "jsonPath",
      "value": "$.theImportantProperty_someNewPropKey"
    }
  }
]