diff --git a/components/json/Get_element_by_index/component.yaml b/components/json/Get_element_by_index/component.yaml new file mode 100644 index 00000000000..ea2d2551622 --- /dev/null +++ b/components/json/Get_element_by_index/component.yaml @@ -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 +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} diff --git a/components/json/Get_element_by_key/component.yaml b/components/json/Get_element_by_key/component.yaml new file mode 100644 index 00000000000..67a8c2593f9 --- /dev/null +++ b/components/json/Get_element_by_key/component.yaml @@ -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 +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} diff --git a/components/json/Query/component.yaml b/components/json/Query/component.yaml new file mode 100644 index 00000000000..89d737be295 --- /dev/null +++ b/components/json/Query/component.yaml @@ -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 +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}