Forrest logo
back to the cat tool

jello:tldr:33ed9

jello: Output the value of multiple keys as a new JSON object (assuming the input JSON has the keys `key_name` and `other_key_name`).
$ cat ${file-json} | jello '{"${my_new_key}": _.${key_name}, "${my_other_key}": _.${other_key_name}}'
try on your machine

This command uses the cat and jello commands in combination to manipulate a JSON file.

Let's break it down step by step:

  1. cat ${file-json} reads the content of the JSON file specified by the variable ${file-json} and outputs it to the standard output.

  2. | is a pipe character, which allows the output of one command (in this case cat) to be used as the input for the next command (in this case jello).

  3. jello is a command-line tool used for JSON manipulation. It takes the input JSON from the standard input and applies transformations based on a provided JSON template.

  4. '{...}' is the JSON template provided to jello. It specifies how to transform or manipulate the input JSON.

  5. "${my_new_key}": _.${key_name} specifies a new key-value pair in the resulting JSON. The value is obtained from the input JSON using the _. notation followed by the value of ${key_name}. The key is assigned the value of ${my_new_key}.

  6. "${my_other_key}": _.${other_key_name} specifies another new key-value pair in the resulting JSON. Similar to the previous step, it retrieves the value from the input JSON using the _. notation.

In summary, this command reads the content of a JSON file, then uses jello to apply a transformation by specifying a JSON template. The template adds or modifies key-value pairs in the output JSON based on values from the input JSON and the provided variables.

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