Jsson Docs

CLI Usage

Complete reference for all JSSON CLI flags and options.

Basic Syntax

jsson -i <file.jsson> [flags]

Transpile Flags

FlagDefaultDescription
-i(required)Input JSSON file
-fjsonOutput format: json, yaml, toml, typescript
-m, --minifyfalseMinify output (no whitespace)
--indent2Number of spaces for indentation
-schema-Schema file to validate output
-validate-onlyfalseOnly validate, don't output
-streamfalseEnable streaming for large datasets
-stream-threshold10000Auto-streaming threshold
-include-mergekeepMerge strategy: keep, overwrite, error

Output Formatting

# Default (pretty, 2 spaces)
jsson -i config.jsson

# Minified (no whitespace)
jsson -i config.jsson -m

# Custom indentation (4 spaces)
jsson -i config.jsson --indent 4

Output Formats

JSON (Default)

jsson -i config.jsson
jsson -i config.jsson -f json

YAML

jsson -i config.jsson -f yaml > config.yaml

TOML

jsson -i config.jsson -f toml > config.toml

TypeScript

Generates TypeScript with as const and inferred types.

jsson -i config.jsson -f typescript > config.ts

Schema Validation

Validate output against JSON Schema:

# Validate and output
jsson -i config.jsson -schema schema.json

# Validate only (no output)
jsson -i config.jsson -schema schema.json -validate-only

Validation output:

✓ Validation passed against schema
✓ Compiled in 1.2ms

On error:

❌ Validation failed against schema (json format):
  • $.user.age: expected integer, got string
    Got: "25"
    Expected: integer

Streaming Mode

For large datasets (100k+ items):

# Enable streaming
jsson -i large-data.jsson -stream

# Custom threshold
jsson -i data.jsson -stream-threshold 50000

Benefits:

  • Memory: ~500MB → under 50MB for 100k items
  • Handles millions of items efficiently

Include Merge Strategies

When files have duplicate keys:

# Keep first definition (default)
jsson -i main.jsson -include-merge keep

# Overwrite with later definition
jsson -i main.jsson -include-merge overwrite

# Error on duplicates
jsson -i main.jsson -include-merge error

Examples

Pipe to jq

jsson -i config.jsson | jq '.users[0]'

Watch and Rebuild

# With entr (Linux)
ls *.jsson | entr -r jsson -i config.jsson > config.json

# With nodemon
nodemon --ext jsson --exec "jsson -i config.jsson > config.json"

CI/CD Integration

# GitHub Actions
- name: Build config
  run: |
    jsson -i config.jsson -f yaml > config.yaml
    jsson -i config.jsson -schema schema.json -validate-only

Makefile

build:
	jsson -i config.jsson > config.json
	jsson -i config.jsson -f yaml > config.yaml

validate:
	jsson -i config.jsson -schema schema.json -validate-only

On this page