Wado

WEP: JSON Literal Compatibility

Date: 2026-01-18 Status: Implemented

Context

Rust is an excellent systems programming language, but it has a significant limitation: describing complex data structures using object literals is cumbersome. While Rust macros can provide solutions (e.g., serde_json::json! macro), Wado has made a deliberate decision not to introduce macros to keep the language simple and maintainable.

Without macros, expressing nested data structures, configuration objects, and test fixtures becomes verbose and error-prone. This would make Wado less productive for common programming tasks, especially in web and application development contexts.

The solution is to make Wado's literal syntax compatible with JSON (JavaScript Object Notation), which is the de facto standard for data interchange on the web. Since JSON syntax is also a subset of JavaScript/TypeScript object literals, this decision provides dual benefits: JSON interoperability and familiarity for web developers.

Decision

Wado's literal syntax is a superset of JSON. Any valid JSON document can be parsed as Wado code, producing dictionaries, arrays, and primitive values.

What's Shared with JSON

Wado Extensions Beyond JSON

While maintaining JSON compatibility, Wado adds developer-friendly extensions:

These extensions are only available in .wado source files, not in imported .json files (see WEP: JSON Module Import for strict parsing behavior).

Tuple Syntax Consistency

An important consequence of JSON compatibility is the choice of tuple syntax. Wado uses [a, b] for tuples rather than Rust's (a, b), ensuring consistency with JSON:

// JSON array maps naturally to Wado tuple
// JSON: [10, 20]
let point: [i32, i32] = [10, 20];

// JSON's heterogeneous arrays map to tuples
// JSON: ["Alice", 25, true]
let user: [String, i32, bool] = ["Alice", 25, true];

This design choice prioritizes JSON interoperability over Rust syntax familiarity. The [...] syntax creates a visual and conceptual consistency: JSON arrays look the same in Wado code, reducing cognitive load for developers working with JSON data.

For homogeneous collections, explicit type annotation or as casting is used:

let numbers: List<i32> = [1, 2, 3];
let names = ["Alice", "Bob"] as List<String>;

Consequences

Benefits

1. Zero Learning Curve for Data Literals

2. Eliminates Need for Macros

3. Ecosystem Integration

4. Type Inference Works Naturally

Trade-offs

1. Tuple Syntax Diverges from Rust

2. Syntax Constraints from JSON

3. Distinction Between .wado and .json Files