Jo - Build JSON Objects from the Shell | Online Free DevTools by Hexmos

Build JSON objects from the shell with Jo. Easily create JSON structures, arrays, and nested objects directly from your command line. Free online tool for developers.

Jo - Shell JSON Builder

Build JSON Objects from the Shell

Jo is a command-line utility that allows you to easily build JSON objects directly from your shell. It simplifies the process of creating structured JSON data without the need for complex scripting or manual formatting. Whether you're working with APIs, configuration files, or scripting tasks, Jo provides a straightforward way to generate JSON.

Key Features and Usage

Jo excels at creating various JSON structures, including simple objects, nested objects, arrays, and combinations thereof. Its intuitive syntax makes it accessible for developers of all levels.

Basic JSON Object Creation

To create a simple JSON object, you can use the key-value pair syntax:

# jo
# Build JSON objects from the shell.

# Basic usage for creating a simple JSON object
jo name=John age=30

Nested JSON Objects

Jo supports creating nested JSON objects by assigning the output of another `jo` command to a key:

# Creating JSON objects with nested objects
jo person=$(jo name=Jane age=25) city=NewYork

JSON Arrays

You can create JSON arrays using the -a flag:

# Creating a JSON array
jo -a apple banana cherry

JSON Objects with Arrays

Combine objects and arrays seamlessly:

# Creating a JSON object with an array
jo fruits=$(jo -a apple banana cherry) type=food

Handling Special Characters and Spaces

For keys or values containing spaces or special characters, use quotes:

# Creating JSON objects with special characters or spaces
jo "name=John Doe" "occupation=Software Engineer"

Numeric and Boolean Values

Jo automatically handles numeric and boolean types:

# Creating JSON objects with numeric values
jo height=170 weight=60.5

# Creating JSON objects with boolean values
jo married=true

Handling Null Values

Represent JSON null values by assigning null:

# Handling JSON null values
jo name=null

Using Shell Variables

Integrate shell variables directly into your JSON objects:

# Creating a JSON object from a shell variable
name=John
age=30
jo name=$name age=$age

# Combining static strings and variables in JSON
color=blue
jo item=car color=$color

Pretty Printing Output

Use the -p flag for formatted, human-readable JSON output:

# Pretty printing JSON output
jo -- "-p" name=Emily age=40

Advanced Array and Nesting

Create complex structures with arrays of objects and deep nesting:

# Creating a JSON array with objects inside
jo -a $(jo name=Alice) $(jo name=Bob)

# JSON object with multiple nested levels
jo user=$(jo name=Chris details=$(jo email=chris@example.com age=28)) status=active

Environment Variables

Jo can also utilize environment variables:

# Using jo with environment variables
export COUNTRY=USA
jo country=$COUNTRY

External Resources