Get value from path
Consider the example input YAML file:
To get a value from a document, the key needs to a path in the document.
For example, getting the value of pswd
:
This will output the value to the command line:
Just about any paths value can be printed to the command line:
This will output:
To output the entire document:
Will result in:
Note
The default output is always YAML. To change the format, add the --output-type
type.
Outputting the same in JSON:
Prints:
Note
If the --output
option in obj
is used to output to a file, the result is not printed to screen.
cURL alternative
Seeing as a Rickle
can be loaded with the JSON response from a URL, it could be used in a cURL-like manner:
Or alternatively
{
"type": "general",
"setup": "Why did the girl smear peanut butter on the road?",
"punchline": "To go with the traffic jam.",
"id": 324
}
with the ability to get a specific value from the JSON response, using paths:
echo https://official-joke-api.appspot.com/random_joke | rickle --output-type JSON obj get /punchline
printing the fantastic punchline to the setup "The punchline often arrives before the set-up.":
Troubleshooting
The most likely problem to occur is if the path can not be traversed, i.e. the path is incorrect:
And this will result in printing nothing (default behaviour).
Another likely problem is that the scalar can not be output in the given type. I.e. TOML, INI, and XML for example need at least a root node.