Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To search for a value and return a scalar, one can use the jq command with the -r flag to return a raw scalar value. The search can be performed using filters.

For example, to search for the value "foo" in a JSON file and return it as a scalar, one can use the following command:

jq -r '.foo' file.json

This will return the value of "foo" as a plain string.

If the value is nested inside a JSON object, you can also use dot notation to navigate to the desired key:

jq -r '.parent.key' file.json

This will return the value of "key" within the "parent" object as a scalar.