Forrest logo
back to the cat tool

jello:tldr:b9cf0

jello: Output the value of a given key of each element in JSON or JSON-Lines data from `stdin` to `stdout`.
$ cat ${file-json} | jello '[i.${key_name} for i in _]'
try on your machine

This command is a combination of two commands: cat and jello.

The cat command is used to read the contents of a file and outputs them to the terminal. In this case, ${file-json} represents the name of a JSON file, and cat ${file-json} is used to display the contents of that JSON file.

The jello command is a command-line tool for manipulating JSON data. It allows you to perform various operations on JSON objects. In this command, the jello command is used to apply a Python expression on the JSON data.

The Python expression, '[i.${key_name} for i in _]', is enclosed in single quotes within the jello command. It is a list comprehension expression that is executed on the input JSON data represented by the _ symbol.

The expression [i.${key_name} for i in _] loops through each object in the input JSON data (_), extracts the value of the key specified by ${key_name}, and creates a new list with those values.

For example, if the input JSON data contains objects with a key called name, and ${key_name} is replaced with name, the expression [i.${key_name} for i in _] will create a list of all the name values from the input JSON data.

Overall, this command is used to extract specific values from a JSON file and display them in a list format.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the cat tool