LinuxCommandLibrary

jello

I cannot provide a relevant tagline

TLDR

Pretty-print JSON or JSON-Lines data from stdin to stdout

$ cat [file.json] | jello
copy

Output a schema of JSON or JSON Lines data from stdin to stdout (useful for grep)
$ cat [file.json] | jello -s
copy

Output all elements from arrays (or all the values from objects) in JSON or JSON-Lines data from stdin to stdout
$ cat [file.json] | jello -l
copy

Output the first element in JSON or JSON-Lines data from stdin to stdout
$ cat [file.json] | jello _[0]
copy

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 _]'
copy

Output the value of multiple keys as a new JSON object (assuming the input JSON has the keys key_name1 and key_name2)
$ cat [file.json] | jello '[{"key1": _.key_name1, "key2": _.key_name2, ...]}'
copy

Output the value of a given key to a string (and disable JSON output)
$ cat [file.json] | jello -r '"[some text]: " + _.[key_name]'
copy

SYNOPSIS

jello [OPTIONS] 'FILTER_EXPRESSION' [FILE...]
jello -f <FILTER_FILE> [OPTIONS] [FILE...]

PARAMETERS

-r, --raw-output
    Output raw strings, without JSON string escaping. Useful for extracting simple text values.

-c, --compact-output
    Produce compact (one-line) output. Eliminates pretty-printing and newline characters.

-s, --slurp
    Read all input as a single array of JSON objects rather than processing line-by-line.

-n, --null-input
    Do not read any input from standard input. Useful when the filter expression itself generates data.

-f <file>, --from-file <file>
    Read the filter expression from the specified file instead of a command-line argument.

-i <num>, --indent <num>
    Sets the indentation level for pretty-printed output. Default is 2. (Requires --compact-output not to be used)

-S, --stream
    Enables streaming input and output, processing JSON elements as they arrive. Useful for very large files or continuous streams.

-v, --version
    Display the version information of the jello command.

-h, --help
    Show a summary of command-line options and usage.

DESCRIPTION

jello is a powerful and lightweight command-line utility designed for processing JSON (JavaScript Object Notation) data. It serves as a modern alternative to tools like jq, built from the ground up in C to achieve high performance and efficiency, particularly with large datasets or streaming input.

The command allows users to filter, transform, and extract specific elements from JSON structures using a concise and expressive filter language, remarkably similar to that of jq. Its primary strength lies in its ability to quickly parse JSON input from standard input or files, apply complex transformations, and output the results in various formats, including raw strings, compact JSON, or pretty-printed JSON.

Whether you need to extract a single field, reshape an entire JSON object, or process a stream of JSON lines, jello provides the necessary tools for efficient JSON manipulation directly from your shell. It's ideal for scripting, data pipelines, and interactive exploration of JSON data.

CAVEATS

While jello offers significant performance advantages due to its C implementation, it is a relatively newer tool compared to the established jq. This means its community support, extensive documentation, and the breadth of its filter language features might not yet match jq's mature ecosystem. Users migrating from jq may find some less common functions or behaviors slightly different or missing, though core functionality is highly compatible. Large-scale deployments might require more thorough testing of its stability and edge-case handling compared to jq.

FILTER EXPRESSIONS

jello uses a powerful filter expression language to select and transform JSON data. This language is heavily inspired by jq, allowing users to navigate objects and arrays (e.g., .key, .[index]), chain operations with pipes (|filter), and apply built-in functions. Understanding these expressions is key to effectively using jello.

INPUT AND OUTPUT

jello can read JSON input from standard input (stdin) or from one or more specified files. It typically processes one JSON object per line by default, but the --slurp option allows treating all input as a single JSON array. Output can be pretty-printed JSON (default), compact JSON (--compact-output), or raw strings (--raw-output), depending on the specified options.

PERFORMANCE CHARACTERISTICS

Being written in C, jello is designed for speed and low resource consumption. This makes it a strong contender for tasks involving very large JSON files, real-time data streaming, or integration into performance-sensitive scripts and pipelines. Its optimized parsing and processing logic aim to outperform similar tools in raw execution speed for many common JSON manipulation tasks.

HISTORY

The jello command emerged as a response to the growing need for faster and more resource-efficient JSON processing on the command line. While jq revolutionized JSON manipulation, its C-based implementation sometimes faced performance limitations with extremely large files or high-throughput streaming scenarios. jello was developed to address these concerns by offering a highly optimized, lightweight alternative written entirely in C. Its development focuses on speed and simplicity, aiming to provide a jq-like experience with a smaller memory footprint and faster execution times, making it particularly suitable for environments where performance is critical, such as data pipelines or embedded systems.

SEE ALSO

jq(1), grep(1), sed(1), awk(1), curl(1)

Copied to clipboard