Transform JSON
JSON - Transform with JSONata
Section titled “JSON - Transform with JSONata”This operation transforms JSON data using JSONata expressions, allowing you to extract, filter, reshape, or create new JSON structures.
Endpoint
Section titled “Endpoint”POST /api/v1/Json/TransformRequest Parameters
Section titled “Request Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| Input | string | Yes | - | Base64-encoded JSON content to transform |
| Transformation | string | Yes | - | JSONata expression to transform the JSON |
| Encoding | string | No | ”UTF8” | Input encoding. Options: “UTF8”, “ASCII”, “Latin1”, “UTF16”, “BigEndianUnicode” |
Response
Section titled “Response”| Name | Type | Description |
|---|---|---|
| output | string | Transformed JSON output |
Implementation Details
Section titled “Implementation Details”The operation uses the JSONata library to transform the provided JSON content. JSONata is a lightweight query and transformation language that provides a concise way to extract, manipulate, and reshape JSON data.
Usage Notes
Section titled “Usage Notes”- Input must be base64 encoded
- A valid JSONata expression is required
- The operation returns an empty string if:
- Input is empty or null
- Transformation is empty or null
- Input is not valid base64-encoded data
- Input cannot be parsed as valid JSON
- Transformation expression is invalid
- Transformation execution fails
Examples
Section titled “Examples”Example 1: Extract a property
Section titled “Example 1: Extract a property”Input (before base64 encoding):
{ "person": { "firstName": "John", "lastName": "Doe", "age": 42 }}Transformation:
person.firstNameOutput:
"John"Example 2: Combine properties
Section titled “Example 2: Combine properties”Input (before base64 encoding):
{ "person": { "firstName": "John", "lastName": "Doe", "age": 42 }}Transformation:
person.firstName & " " & person.lastNameOutput:
"John Doe"Example 3: Filter and transform an array
Section titled “Example 3: Filter and transform an array”Input (before base64 encoding):
{ "people": [ { "name": "John", "age": 42, "active": true }, { "name": "Jane", "age": 35, "active": false }, { "name": "Bob", "age": 29, "active": true } ]}Transformation:
people[active=true].{ "fullName": name, "yearsOld": age}Output:
[ { "fullName": "John", "yearsOld": 42 }, { "fullName": "Bob", "yearsOld": 29 }]Credit Cost
Cost: 0.1 credit(s) per operation
Note: Fixed cost per transformation