-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): Added JSON query components (#4601)
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Get element by index from JSON | ||
inputs: | ||
- {name: Json} | ||
- {name: Index, type: Integer} | ||
outputs: | ||
- {name: Output} | ||
metadata: | ||
annotations: | ||
author: Alexey Volkov <alexey.volkov@ark-kun.com> | ||
implementation: | ||
container: | ||
image: stedolan/jq:latest | ||
command: | ||
- sh | ||
- -exc | ||
- | | ||
input_path=$0 | ||
output_path=$1 | ||
index=$2 | ||
mkdir -p "$(dirname "$output_path")" | ||
< "$input_path" jq --raw-output .["$index"] > "$output_path" | ||
- {inputPath: Json} | ||
- {outputPath: Output} | ||
- {inputValue: Index} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Get element by key from JSON | ||
inputs: | ||
- {name: Json} | ||
- {name: Key, type: String} | ||
outputs: | ||
- {name: Output} | ||
metadata: | ||
annotations: | ||
author: Alexey Volkov <alexey.volkov@ark-kun.com> | ||
implementation: | ||
container: | ||
image: stedolan/jq:latest | ||
command: | ||
- sh | ||
- -exc | ||
- | | ||
input_path=$0 | ||
output_path=$1 | ||
key=$2 | ||
mkdir -p "$(dirname "$output_path")" | ||
< "$input_path" jq --raw-output '.["'"$key"'"]' > "$output_path" | ||
- {inputPath: Json} | ||
- {outputPath: Output} | ||
- {inputValue: Key} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Query JSON using JQ | ||
inputs: | ||
- {name: Json} | ||
- {name: Query, type: String} | ||
- {name: Options, type: String, default: '--raw-output'} | ||
outputs: | ||
- {name: Output} | ||
metadata: | ||
annotations: | ||
author: Alexey Volkov <alexey.volkov@ark-kun.com> | ||
implementation: | ||
container: | ||
image: stedolan/jq:latest | ||
command: | ||
- sh | ||
- -exc | ||
- | | ||
input_path=$0 | ||
output_path=$1 | ||
query=$2 | ||
options=$3 | ||
mkdir -p "$(dirname "$output_path")" | ||
< "$input_path" jq $options "$query" > "$output_path" | ||
- {inputPath: Json} | ||
- {outputPath: Output} | ||
- {inputValue: Query} | ||
- {inputValue: Options} |