Jq Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 12: Line 12:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
echo \"red\" \"blue\" \"green\" | jq '.'
echo \"red\" \"blue\" \"green\" | jq '.'
</syntaxhighlight>
This is how an array can be injected in the pipeline:
<syntaxhighlight lang='bash'>
echo "[\"red\", \"blue\"]" | jq '.'
</syntaxhighlight>
... and this is how a map can be injected in the pipeline:
<syntaxhighlight lang='bash'>
echo "{\"size\": 10}" | jq '.'
</syntaxhighlight>
</syntaxhighlight>



Revision as of 19:18, 1 March 2019

Internal

Pipeline Content

The pipeline flows primitives, maps and arrays.

Individual strings flowing on a pipeline can be simulated with:

echo \"red\" \"blue\" \"green\" | jq '.'

This is how an array can be injected in the pipeline:

echo "[\"red\", \"blue\"]" | jq '.'

... and this is how a map can be injected in the pipeline:

echo "{\"size\": 10}" | jq '.'

Iteration

An iteration is pipeline content produced by the .[] filter, that converts and array into its individual elements.

Organizatorium

Conversion from a map to an array.

Conversion from array to a map?