2021-06-12 15:30:03 +01:00
|
|
|
# jello
|
|
|
|
|
|
|
|
> A command-line JSON processor using Python syntax.
|
|
|
|
> More information: <https://github.com/kellyjonbrazil/jello>.
|
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Pretty-print JSON or JSON-Lines data from `stdin` to `stdout`:
|
2021-06-12 15:30:03 +01:00
|
|
|
|
|
|
|
`cat {{file.json}} | jello`
|
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Output a schema of JSON or JSON Lines data from `stdin` to `stdout` (useful for grep):
|
2021-06-12 15:30:03 +01:00
|
|
|
|
|
|
|
`cat {{file.json}} | jello -s`
|
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Output all elements from arrays (or all the values from objects) in JSON or JSON-Lines data from `stdin` to `stdout`:
|
2021-06-12 15:30:03 +01:00
|
|
|
|
|
|
|
`cat {{file.json}} | jello -l`
|
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Output the first element in JSON or JSON-Lines data from `stdin` to `stdout`:
|
2021-06-12 15:30:03 +01:00
|
|
|
|
|
|
|
`cat {{file.json}} | jello _[0]`
|
|
|
|
|
2022-12-04 07:53:34 +00:00
|
|
|
- Output the value of a given key of each element in JSON or JSON-Lines data from `stdin` to `stdout`:
|
2021-06-12 15:30:03 +01:00
|
|
|
|
|
|
|
`cat {{file.json}} | jello '[i.{{key_name}} for i in _]'`
|
|
|
|
|
2024-01-31 03:55:19 +00:00
|
|
|
- Output the value of multiple keys as a new JSON object (assuming the input JSON has the keys `key_name1` and `key_name2`):
|
2021-06-12 15:30:03 +01:00
|
|
|
|
2024-01-31 03:55:19 +00:00
|
|
|
`cat {{file.json}} | jello '{"{{key1}}": _.{{key_name1}}, "{{key_name}}": _.{{key_name2}}}'`
|
2021-06-12 15:30:03 +01:00
|
|
|
|
|
|
|
- Output the value of a given key to a string (and disable JSON output):
|
|
|
|
|
|
|
|
`cat {{file.json}} | jello -r '"{{some text}}: " + _.{{key_name}}'`
|