Supported in: Batch, Streaming
Parses JSON string following the given schema definition, ignoring any fields not in the schema.
Expression categories: Data preparation, Popular, String, Struct
Output type: Array<AnyType> | Map<String, String> | Struct
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK", "miles": 2000 } } | { airline: XB-112, airport: { id: JFK, miles: 2000, }, } |
Argument values:
jsonWITH_ERRORS| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK", "miles": 2000 } } | { error: null, ok: { airline: XB-112, airport: { id: JFK, miles: 2000, }, }, } |
Description: When a requested field is missing in the input JSON the field becomes null.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK" } } | { airline: XB-112, airport: { id: JFK, miles: null, }, } |
Argument values:
json| json | Output |
|---|---|
| null | null |
Argument values:
jsonWITH_ERRORS| json | Output |
|---|---|
| null | { error: JSON input is null or empty, ok: null, } |
Description: When a requested field is null in the input JSON the field becomes null.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK", "miles": null } } | { airline: XB-112, airport: { id: JFK, miles: null, }, } |
Description: Test field of struct being an array.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK", "countries": ["USA", "Canada"] } } | { airline: XB-112, airport: { countries: [ USA, Canada ], id: JFK, }, } |
Description: Test field of struct being empty string.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "", "countries": ["USA", "Canada"] } } | { airline: XB-112, airport: { countries: [ USA, Canada ], id: empty string, }, } |
Description: Test field of struct being an array with null element.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK", "countries": ["USA", null] } } | { airline: XB-112, airport: { countries: [ USA, null ], id: JFK, }, } |
Description: Test field of struct being a null string.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": null, "countries": ["USA", "Canada"] } } | { airline: XB-112, airport: { countries: [ USA, Canada ], id: null, }, } |
Description: Test struct with one field being a map.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK", "countries": {"USA": 4} } } | { airline: XB-112, airport: { countries: { USA -> 4, }, id: JFK, }, } |
Description: Parse struct with double field.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK", "miles": 4.2 } } | { airline: XB-112, airport: { id: JFK, miles: 4.2, }, } |
Description: Ints parsed as doubles should return doubles.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK", "miles": 4 } } | { airline: XB-112, airport: { id: JFK, miles: 4.0, }, } |
Description: When a map has a null value, the resultant struct will have a null value.
Argument values:
json| json | Output |
|---|---|
| { "airline": "XB-112", "airport": { "id": "JFK", "countries": {"USA": null} } } | { airline: XB-112, airport: { countries: { USA -> null, }, id: JFK, }, } |
Argument values:
jsonWITH_ERRORS| json | Output |
|---|---|
| invalid | { error: The JSON content is invalid or malformed, ok: null, } |
Argument values:
jsonWITH_ERRORS| json | Output |
|---|---|
| { "timestampVal": "This is a string." } | { error: The JSON content does not match the expected type, ok: null, } |
| {"boolVal": 5} | { error: The JSON content does not match the expected type, ok: null, } |
| {"byteVal": "This is not a byte."} | { error: The JSON content does not match the expected type, ok: null, } |
| {"shortVal": "This is not a short."} | { error: The JSON content does not match the expected type, ok: null, } |
| {"longVal": "This is not a long."} | { error: The JSON content does not match the expected type, ok: null, } |
| {"intVal": 5.2} | { error: The JSON content does not match the expected type, ok: null, } |
| {"doubleVal": "This is not a double."} | { error: The JSON content does not match the expected type, ok: null, } |
| {"floatVal": "This is not a float."} | { error: The JSON content does not match the expected type, ok: null, } |
| {"dateVal": "32/13/2020"} | { error: The JSON content does not match the expected type, ok: null, } |
| {"decimalVal": "This is not a decimal."} | { error: The JSON content does not match the expected type, ok: null, } |
| {"myMap": {"a": "str"}} | { error: The JSON content does not match the expected type, ok: null, } |
| {"myArray": ["a", "b"]} | { error: The JSON content does not match the expected type, ok: null, } |
Argument values:
jsonWITH_ERRORS| json | Output |
|---|---|
| { "boolVal": true } | { error: null, ok: { airport: null, boolVal: true, }, } |
| { "boolVal": "This is a string." } | { error: The JSON content does not match the expected type, ok: null, } |
Argument values:
jsonWITH_ERRORS| json | Output |
|---|---|
| { "arrival_time": | { error: There was an unexpected EOF while parsing the JSON, ok: null, } |