JSON-Path for your requirement.

json-path <source-column> <destination-column> <expression>
<source-column>specifies the column in the record that should be considered as the “root member object” or ”$”<destination-column>is the name of the output column in the record where the results of the expression will be stored<expression>is a JSON path expression; see Usage Notes below for details
Use Case: Extracting First Name from Ingested Object Data in Zeotap CDP
Assume that you have ingested an “Object” type data into Zeotap CDP that has a property, First name, which needs to be extracted as a new field in your Catalogue. Here, you can use the directive JSON Path to extract the required field as mentioned below.Directives for Data Transformation
Code
Note:For more information on this directive, JSON Path. refer here.
| Directive | Description |
|---|---|
set-column dataFields json:Parse(dataFields) | Parses the dataFields column into a JSON format, facilitating easier manipulation and extraction of data. |
json-path dataFields firstName '$[?(@.key == "firstName")].value' | Uses JSON Path to locate the firstName key within the dataFields JSON object and extracts its corresponding value. |
flatten :firstName | Ensures that the firstName field is flattened into a simple, single-level structure, ready for further processing or analysis. |