# JsonPath

> JsonPath transform plugin

### Description[​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#description) <a href="#description" id="description"></a>

> Support use jsonpath select data

### Options[​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#options) <a href="#options" id="options"></a>

| name    | type  | required | default value |
| ------- | ----- | -------- | ------------- |
| Columns | Array | Yes      |               |

#### common options \[string][​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#common-options-string) <a href="#common-options-string" id="common-options-string"></a>

Transform plugin common parameters, please refer to [Transform Plugin](https://docs.selfuel.digital/data-integration-with-nexus/nexus-elements/transform/transform-common-options) for details

#### fields\[array][​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#fieldsarray) <a href="#fieldsarray" id="fieldsarray"></a>

**option**[**​**](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#option)

| name        | type   | required | default value |
| ----------- | ------ | -------- | ------------- |
| src\_field  | String | Yes      |               |
| dest\_field | String | Yes      |               |
| path        | String | Yes      |               |
| dest\_type  | String | No       | String        |

**src\_field**[**​**](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#src_field)

> the json source field you want to parse

Support NexusDateType

* STRING
* BYTES
* ARRAY
* MAP
* ROW

**dest\_field**[**​**](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#dest_field)

> after use jsonpath output field

**dest\_type**[**​**](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#dest_type)

> the type of dest field

**path**[**​**](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#path)

> Jsonpath

### Read Json Example[​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#read-json-example) <a href="#read-json-example" id="read-json-example"></a>

The data read from source is a table like this json:

```
{
  "data": {
    "c_string": "this is a string",
    "c_boolean": true,
    "c_integer": 42,
    "c_float": 3.14,
    "c_double": 3.14,
    "c_decimal": 10.55,
    "c_date": "2023-10-29",
    "c_datetime": "16:12:43.459",
    "c_array":["item1", "item2", "item3"]
  }
}
```

Assuming we want to use JsonPath to extract properties.

```
transform {
  JsonPath {
    source_table_name = "fake"
    result_table_name = "fake1"
    columns = [
     {
        "src_field" = "data"
        "path" = "$.data.c_string"
        "dest_field" = "c1_string"
     },
     {
        "src_field" = "data"
        "path" = "$.data.c_boolean"
        "dest_field" = "c1_boolean"
        "dest_type" = "boolean"
     },
     {
        "src_field" = "data"
        "path" = "$.data.c_integer"
        "dest_field" = "c1_integer"
        "dest_type" = "int"
     },
     {
        "src_field" = "data"
        "path" = "$.data.c_float"
        "dest_field" = "c1_float"
        "dest_type" = "float"
     },
     {
        "src_field" = "data"
        "path" = "$.data.c_double"
        "dest_field" = "c1_double"
        "dest_type" = "double"
     },
      {
         "src_field" = "data"
         "path" = "$.data.c_decimal"
         "dest_field" = "c1_decimal"
         "dest_type" = "decimal(4,2)"
      },
      {
         "src_field" = "data"
         "path" = "$.data.c_date"
         "dest_field" = "c1_date"
         "dest_type" = "date"
      },
      {
         "src_field" = "data"
         "path" = "$.data.c_datetime"
         "dest_field" = "c1_datetime"
         "dest_type" = "time"
      },
            {
         "src_field" = "data"
         "path" = "$.data.c_array"
         "dest_field" = "c1_array"
         "dest_type" = "array<string>"        
      }
    ]
  }
}
```

Then the data result table `fake1` will like this

| data                         | c1\_string       | c1\_boolean | c1\_integer | c1\_float | c1\_double | c1\_decimal | c1\_date   | c1\_datetime | c1\_array                    |
| ---------------------------- | ---------------- | ----------- | ----------- | --------- | ---------- | ----------- | ---------- | ------------ | ---------------------------- |
| too much content not to show | this is a string | true        | 42          | 3.14      | 3.14       | 10.55       | 2023-10-29 | 16:12:43.459 | \["item1", "item2", "item3"] |

### Read NexusRow Example[​](https://seatunnel.apache.org/docs/2.3.7/transform-v2/jsonpath#read-seatunnelrow-example) <a href="#read-seatunnelrow-example" id="read-seatunnelrow-example"></a>

Suppose a column in a row of data is of type NexusRow and that the name of the column is col

| NexusRow(col) | other |      |
| ------------- | ----- | ---- |
| name          | age   | .... |
| a             | 18    | .... |

The JsonPath transform converts the values of Nexus into an array,

```
transform {
  JsonPath {
    source_table_name = "fake"
    result_table_name = "fake1"
    columns = [
     {
        "src_field" = "col"
        "path" = "$[0]"
        "dest_field" = "name"
            "dest_type" = "string"
     },
        {
        "src_field" = "col"
        "path" = "$[1]"
        "dest_field" = "age"
            "dest_type" = "int"
     }
    ]
  }
}
```

Then the data result table `fake1` will like this

| name | age | col       | other |
| ---- | --- | --------- | ----- |
| a    | 18  | \["a",18] | ...   |
