Allows performing JSONata operations and transformations on a JSON file in the workspace.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| as | string | - | |
| path | string | - | |
| space | string | - | |
| replacer | array | - | |
| expression | string | - |
Output Schema
| Property | Type | Description | Required |
|---|---|---|---|
| result | any | - |
Usage Examples
Extract a service summary from package.json
Extracts key metadata from package.json into a compact object. Use this when you need to compute values from existing files earlier in the workflow after fetch:template.
steps:
- id: fetch-base
action: fetch:template
input:
url: ./skeletons/node-service
targetPath: .
values:
name: ${{ parameters.name }}
- id: summarize-package
action: roadiehq:utils:jsonata:json:transform
input:
path: package.json
expression: |
{
"name": name,
"version": version,
"dependenciesCount": dependencies ? $count($keys(dependencies)) : 0,
"devDependenciesCount": devDependencies ? $count($keys(devDependencies)) : 0,
"nodeEngine": engines.node ? engines.node : ">=18"
}
as: objectSelect and format production endpoints from environments.json
Filters prod environments and returns a pretty-printed JSON string with only the name and url fields. Use this to produce a curated JSON snippet you can write or publish after fetch:template.
steps:
- id: fetch-config
action: fetch:template
input:
url: ./skeletons/service-with-envs
targetPath: .
values:
serviceId: ${{ parameters.serviceId }}
- id: prod-endpoints
action: roadiehq:utils:jsonata:json:transform
input:
path: config/environments.json
expression: |
$map(environments[type="${{ parameters.targetEnv | default('prod') }}"], function($e) {
{"name": $e.name, "url": $e.url}
})
replacer:
- name
- url
space: "2"
as: stringGenerate .env content from a JSON config
Builds .env formatted content from an env object in config/app.json. Use when you need to derive a .env file from structured config produced by fetch:template.
steps:
- id: fetch-app
action: fetch:template
input:
url: ./skeletons/web-app
targetPath: .
values:
region: ${{ parameters.region }}
- id: env-from-json
action: roadiehq:utils:jsonata:json:transform
input:
path: config/app.json
expression: |
$join(
$map($keys(env), function($k) { $k & "=" & env[$k] }),
"\n"
)
as: stringCompute Docker image tags from build metadata
Computes a list of semantic version tags from a build.json version. Use this to consistently generate tags used in later steps of your pipeline after fetch:template.
steps:
- id: fetch-build
action: fetch:template
input:
url: ./skeletons/containerized-service
targetPath: .
values:
imageName: ${{ parameters.imageName }}
- id: compute-tags
action: roadiehq:utils:jsonata:json:transform
input:
path: ci/build.json
expression: |
(
$v := $split(version, ".");
[version, $v[0] & "." & $v[1], $v[0]]
)
as: objectSanitize a config by whitelisting fields
Returns the full JSON document but stringified with only safe top-level keys included. Use this to produce a redacted config string you can store or publish, after fetch:template.
steps:
- id: fetch-config-base
action: fetch:template
input:
url: ./skeletons/service-config
targetPath: .
values:
serviceName: ${{ parameters.name }}
- id: redact-config
action: roadiehq:utils:jsonata:json:transform
input:
path: config/service.json
expression: "$" # return the whole document
replacer:
- serviceName
- public
- features
- endpoints
space: "2"
as: string