Jsson Docs

Changelog

List of changes and improvements by version.

v0.0.6 — Presets & Validators (2025-12-25)

New Features

Presets System 🎨

Define reusable configuration templates with @preset and apply them with @use. Perfect for sharing common settings across multiple objects.

Defining a preset:

@preset "api_defaults" {
  timeout = 30
  retries = 3
  ssl = true
  headers = ["Content-Type", "Authorization"]
}

Using a preset:

services {
  auth = @use "api_defaults" {
    port = 8080
    path = "/auth"
  }
  
  payment = @use "api_defaults" {
    port = 8081
    path = "/payment"
    timeout = 60  // Override default
  }
}

Key Features:

  • Define once, reuse everywhere
  • Override any preset value
  • Merge preset values with custom properties
  • Perfect for DRY configuration

Validators 🔐

Auto-generate valid data with built-in validators. Perfect for testing, mocking, and seeding databases.

Available validators:

user {
  // UUID generation
  id = @uuid
  
  // Email generation
  email = @email
  
  // URL generation
  website = @url
  
  // IP addresses
  ipv4 = @ipv4
  ipv6 = @ipv6
  
  // Dates and times
  created_at = @datetime
  birth_date = @date
  
  // File paths
  config_file = @filepath
  
  // Random numbers with ranges
  age = @int(18, 65)
  score = @float(0.0, 100.0)
  
  // Random boolean
  active = @bool
}

Use cases:

  • Generate test data
  • Mock API responses
  • Database seeding
  • Placeholder values

Built-in HTTP Server 🌐

Serve your JSSON configurations directly via HTTP with the new --serve flag. Perfect for distributing configs across your infrastructure without redeployment.

Starting the server:

# Basic server on default port 8080
jsson --serve -i config.jsson

# Custom port
jsson --serve --port 3000 -i config.jsson

# Serve with specific output format
jsson --serve --format yaml -i config.jsson

Fetching configurations:

# Get JSON output
curl http://localhost:8080/config

# Use in your services
fetch('http://config-server:8080/config')
  .then(res => res.json())
  .then(config => console.log(config))

Key Features:

  • Production-ready lightweight server
  • Hot-reload on file changes
  • CORS support for web clients
  • Multiple output formats (JSON, YAML, TOML)
  • Zero configuration required

CLI Improvements 🛠️

New Flags:

  • --serve / -s: Start HTTP server mode
  • --port: Specify server port (default: 8080)
  • --minify / -m: Output minified JSON (no whitespace)
  • --indent: Custom indentation (default: 2 spaces)

Examples:

# Minified output
jsson -i config.jsson --minify

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

# Serve on custom port
jsson --serve --port 9000 -i prod.jsson

Boolean Literals 💡

Use yes/no and on/off as more readable alternatives to true/false.

features {
  // Standard booleans
  enabled = true
  disabled = false
  
  // Yes/No style (great for configs)
  dark_mode = yes
  analytics = no
  
  // On/Off style (great for toggles)
  cache = on
  debug = off
}

All four styles (true/false, yes/no, on/off) are equivalent and can be mixed freely.

Bug Fixes

Int/Float Comparison Fix 🔧

Fixed comparison operators to correctly handle mixed int/float comparisons. Previously, comparing integers with floats would fail.

Before (broken):

value = 10
result = value > 9.5  // ❌ Error: type mismatch

After (fixed):

value = 10
result = value > 9.5  // ✅ Works! result = true

price = 99.99
discount = price < 100  // ✅ discount = true

Bare Identifier Handling 🏷️

Improved error messages for undefined variables. Now requires explicit quotes for string literals to avoid ambiguity.

Rule: Variables have priority over bare identifiers. Always use quotes for string values.

// ✅ Correct
name = "Alice"
status = "active"

// ❌ Wrong (treated as undefined variables)
name = Alice
status = active

Better error messages:

Error: variable 'Alice' not found
Did you mean to use a string? Try: name = "Alice"

Examples

Complete Example: User Management with Presets & Validators

// Define preset for common user fields
@preset "user_defaults" {
  role = "user"
  active = true
  permissions = ["read"]
  created_at = @datetime
}

// Admin preset extends user defaults
@preset "admin_defaults" {
  role = "admin"
  active = true
  permissions = ["read", "write", "delete", "admin"]
  created_at = @datetime
}

// Generate users with validators
users [
  template { name, type }
  
  map (u) = @use (u.type == "admin" ? "admin_defaults" : "user_defaults") {
    id = @uuid
    name = u.name
    email = u.name + "@example.com"
    age = @int(25, 60)
    verified = @bool
  }
  
  "Alice", "admin"
  "Bob", "user"
  "Charlie", "user"
]

v0.0.5.2 — Variable Arithmetic Fix (2025-12-02)

Bug Fixes

Variable Arithmetic Operations 🔧

Fixed a critical bug where arithmetic operations using variables would fail with "unsupported binary operation" errors. Previously, assignment statements (price = 100) were not stored in the symbol table, causing subsequent references to be treated as undefined identifiers instead of their numeric values.

Before (broken):

price = 100
tax = 15
total = price + tax  // ❌ Error: unsupported binary operation

After (fixed):

price = 100
tax = 15
total = price + tax  // ✅ Works! total = 115

discount = 20
final = total - discount  // ✅ final = 95

Technical Details:

  • Modified Transpiler.Transpile() to store assignment values in both the symbol table and output
  • File: internal/transpiler/transpiler.go (line 75)
  • Now assignments can be referenced in subsequent expressions

Examples:

// Chained calculations
quantity = 5
itemPrice = 10
subtotal = quantity * itemPrice  // 50

// Mixed operations
base = 100
withTax = base + 15      // 115
withDiscount = withTax - 10  // 105
doubled = withDiscount * 2   // 210

New Features

Compilation Timer ⏱️

Added compilation time measurement to both CLI and playground for performance visibility.

CLI:

$ jsson -i config.jsson > output.json
 Compiled in 552.6µs
  • Auto-formats time units: µs, ms, or s
  • Printed to stderr (doesn't interfere with output redirection)
  • Helps identify performance bottlenecks

Playground:

  • Real-time performance feedback in output footer
  • Auto-formatted display (µs/ms/s)
  • Green checkmark indicator

Streaming Support for Large Datasets 🚀

Added streaming infrastructure for efficient handling of large data volumes.

CLI Flags:

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

# Auto-enable for ranges > N items (default: 10,000)
jsson -i data.jsson --stream-threshold 5000

Features:

  • Memory reduction: ~500MB → < 50MB for 100k items
  • Lazy evaluation with RangeIterator
  • Automatic threshold detection

Other Improvements

  • Added 40+ edge case tests to improve robustness
  • Created comprehensive test suite for variable arithmetic
  • Updated WASM binary with all fixes

v0.0.5.1 — Parser Bug Fixes (2025-11-29)

Bug Fixes

Nested Ternary Operators

Fixed parsing of chained ternary expressions. Previously, expressions like 5 > 3 ? 10 > 8 ? "yes" : "maybe" : "no" would fail with a parser error. Now they work correctly with proper right-associativity.

Technical Details:

  • Changed precedence to TERNARY - 1 for both consequence and alternative branches in parseConditionalExpression
  • File: internal/parser/parser.go

Negative Number Ranges

Fixed support for ranges starting with negative numbers. Previously, -5..5 would fail. Now it works correctly.

Technical Details:

  • Modified parsePrefixExpression to create negative IntegerLiteral and FloatLiteral directly instead of BinaryExpression(0 - value)
  • File: internal/parser/parser.go

Range-Map Expressions

Fixed parsing of map expressions applied to ranges. Previously, 1..3 map (x) = x * 2 required parentheses: (1..3) map (x) = x * 2. Now it works without parentheses.

Technical Details:

  • Reorganized operator precedence: CALL < RANGE < MAP < INDEX
  • Changed parseRangeExpression to use MAP precedence for end value parsing
  • File: internal/parser/parser.go

Note: Arithmetic in range end values requires parentheses for clarity: i..(i+2) ✅, not i..i+2 ❌ (ambiguous)

Array Templates with Map in Objects

Fixed support for array templates with map clauses when used as object properties. Previously, this would fail:

templates {
  withMap [
    template { id, value }
    map (item) = { id = item.id * 10 }
    1, "test"
  ]
}

Technical Details:

  • Changed parseObjectLiteral to call parseArrayTemplate() directly instead of parseArrayLiteral()
  • File: internal/parser/parser.go

Error Line Number Reporting

Fixed error messages to show the correct line number instead of always showing line:1:1. Now errors accurately point to the exact line and column where the problem occurred.

Technical Details:

  • Added missing AST node types to error reporting switch cases: MapExpression, ConditionalExpression, InterpolatedString, BooleanLiteral
  • File: internal/transpiler/transpiler.go

Examples

// Nested ternaries
status = age > 18 ? score > 80 ? "excellent" : "good" : "minor"

// Negative ranges
temperatures = -10..10

// Range-map without parentheses
doubled = 1..5 map (x) = x * 2

// Templates with map in objects
config {
  users [
    template { id, name }
    map (u) = { id = u.id * 100, name = u.name }
    1, "Alice"
    2, "Bob"
  ]
}

v0.0.5 — Nested Logic Power-Up (2025-11-28)

New Features

Nested map() Support 🔄

JSSON now allows map() transformations inside other map() transformations. This enables multi-level pipelines, matrix-like generation, combinatorial data creation, and far more expressive logic.

Example:

nested = (0..2 map (g) = (5..6 map (x) = g + x))

Full Support for Nested Arrays 📦

Nested arrays now work everywhere:

  • Inside templates
  • Inside map clauses
  • As direct literal values
  • As intermediate evaluated expressions

JSSON automatically expands, flattens, or structures arrays as needed without losing context.

Universal Range Expressions 🔢

Ranges (0..N) now work in all places where expressions are allowed:

  • Inside arrays
  • Inside map arguments
  • Inside templates
  • Nested within other ranges
  • Used as part of deeper transformations

This makes large-scale data generation extremely simple:

0..9999

Variable Declarations (:=) 📦

Declare variables for reuse and cleaner configuration. Variables are scoped and support shadowing.

host := "localhost"
port := 8080
url = host + ":" + port

Arithmetic Improvements (Division & Modulo) ➗

Arithmetic is now fully stable for / and %.

Modulo (%) and division (/) now work inside map logic, expressions, and nested operations.

Example:

hash = "uid-" + (u.id * 91 % 17)

Invalid operations (like applying modulo directly to an entire range literal) now produce clear semantic errors instead of causing crashes.

Stability & Internal Improvements

  • Better handling of RangeResult values during deep transformations
  • More reliable evaluation order for nested arrays and nested maps
  • Improved safety checks to prevent unexpected binary operations on non-scalar values
  • Cleaner error messages that explain exactly where an invalid operation was attempted
  • Internal prep for future collection operators and functional features

Summary

JSSON v0.0.5 turns the language into a true data-generation powerhouse:

  • Unlimited nesting
  • Unlimited ranges
  • Stable math
  • Cleaner semantics
  • Smarter expansion rules

Large-scale data creation is now faster, safer, and easier than ever.


v0.0.4 — Universal Meta-Format (2025-11-26)

New Features

Multi-Format Transpilation 🚀

JSSON is no longer just for JSON. You can now transpile your JSSON files into 4 different formats:

  • JSON (Default)
  • YAML (-f yaml)
  • TOML (-f toml)
  • TypeScript (-f typescript)

TypeScript Type Generation

When transpiling to TypeScript, JSSON automatically generates:

  • as const assertions for immutability
  • Exported type definitions (export type Config = typeof config)
  • Fully typed objects ready for use in your frontend or backend

CLI Updates

  • Added -f / --format flag to specify output format.
  • Improved error messages for invalid formats.

Website & Playground

  • New Playground: Now supports tabs for JSON, YAML, TOML, and TypeScript outputs.
  • Privacy & Terms: Added legal pages to ensure transparency.
  • Landing Page: Updated to reflect JSSON's new universal capabilities.

v0.0.3.1 2025-11-25

Bug Fixes

  • Fixed support negative numbers in expressions.
  • Added unary minus operator support for negative numbers.

v0.0.3 — Arrays in Objects & Real-World Examples (2025-11-25)

New Features

Arrays as Object Property Values

You can now use arrays directly as object property values!

config {
  methods = ["GET", "POST", "PUT", "DELETE"]
  ports = [8080, 8081, 8082]
  tags = ["api", "v1", "production"]
}

This unlocks powerful new use cases:

  • API gateway configurations with allowed methods
  • Kubernetes configs with container ports
  • Feature flags with target user segments
  • And much more!

Arrays in Map Clauses

Map transformations can now include array properties:

routes [
  template { service }

  map (r) = {
    service = r.service
    allowMethods = ["GET", "POST", "PUT"]
    allowHeaders = ["Content-Type", "Authorization"]
  }

  "auth"
  "payment"
]

Real-World Examples

Added 6 comprehensive real-world examples demonstrating JSSON's power:

  1. Geographic Data — Generate millions of coordinate records
  2. Kubernetes Configuration — Multi-environment deployments
  3. API Gateway — Microservices routing with rate limiting
  4. i18n Translations — Multi-language translation management
  5. Feature Flags — Environment-specific configuration
  6. Database Seeding — Relational data with foreign keys

Each example includes:

  • Complete JSSON code
  • JSON output samples
  • Explanation of techniques used
  • When to use the pattern

Parser Improvements

  • Enhanced parseObjectLiteral to support array literals as property values
  • Better error messages for syntax issues
  • Improved handling of nested structures

Documentation

  • New "Real-World Use Cases" section in docs
  • Overview page explaining production scenarios
  • Individual pages for each example with detailed explanations
  • Updated SEO keywords for better discoverability

Bug Fixes

  • Fixed parsing of complex nested objects with arrays
  • Improved transpiler handling of mixed data structures

Performance

JSSON v0.0.3 can now handle even more complex scenarios:

  • ~500 lines of JSSON → 600+ JSON records
  • Ratios up to 50,000:1 for large-scale data generation

v0.0.2 — Arithmetic & Conditional Logic (2025-11-24)

Features

  • Arithmetic operators: +, -, *, /, %
  • Comparison operators: ==, !=, >, <, >=, <=
  • Ternary operator: condition ? true : false
  • Map transformations with conditional logic
  • String concatenation in expressions

Examples

users [
  template { name, age }

  map (u) = {
    name = u.name
    age = u.age
    isAdult = u.age >= 18
    category = u.age >= 18 ? "adult" : "minor"
  }

  "João", 25
  "Maria", 16
]

v0.0.1 — Initial Release (2025-11-23)

Features

  • Core parser for JSSON syntax
  • Template arrays for structured data
  • Range expressions (1..100)
  • Include statements for file composition
  • CLI tool for transpilation
  • Basic data types: strings, numbers, booleans, objects, arrays

Examples

users [
  template { name, age }

  "João", 19
  "Maria", 25
]

ports = 8080..8085

What's Next?

Future versions may include:

  • Functions/macros
  • Array methods (filter, map, reduce)
  • More advanced control flow

Stay tuned!

On this page