# std.json

JSON values with checked parsing and schema validation.

```tea
use json from "std.json"
```

Examples may be fragments requiring the module import or additional setup.

## std.json.encode

```tea
pub def encode[T](value: T) -> String
```

Encode a value as JSON. Use Dynamic explicitly for heterogeneous dictionaries and lists.

## std.json.decode

```tea
pub def decode[T](text: String) -> T ! DecodeError
```

Parse JSON and validate every nested value against T before returning. Supports Int, Float, Bool, String, List, Dict, optional values, and Dynamic. JSON objects remain dictionaries; nominal structs require explicit construction.

```tea
use json from "std.json"

const config = json.decode[Dict[String, String]](`{"theme":"dark"}`)
@println(config["theme"] ?? "default") # dark
```
