# json.lazy

> A module of json_mlake's API.

## Structs

### `LazyValue`

```mojo
struct LazyValue
```

A lazily-parsed JSON value.

Unlike Value, LazyValue stores the raw JSON and only parses
when you access specific fields or elements. This is efficient
for large documents where you only need a few values.

Example:
var lazy = loads_lazy(huge_json_string)
var name = lazy.get("/users/0/name")
Only parses the path to "users/0/name", not the whole document.

Implements: `Movable`

#### `__init__`

```mojo
def __init__(out self, raw: String)
```

Create a LazyValue from raw JSON string.

#### `__getitem__`

```mojo
def __getitem__(self, key: String) -> Self
```

Get object field as a new LazyValue.

Args:

- `key`: Object key.

```mojo
def __getitem__(self, index: Int) -> Self
```

Get array element as a new LazyValue.

Args:

- `index`: Array index.

#### `is_null`

```mojo
def is_null(mut self) -> Bool
```

Check if value is null.

#### `is_bool`

```mojo
def is_bool(mut self) -> Bool
```

Check if value is a boolean.

#### `is_int`

```mojo
def is_int(mut self) -> Bool
```

Check if value is an integer.

#### `is_float`

```mojo
def is_float(mut self) -> Bool
```

Check if value is a float.

#### `is_string`

```mojo
def is_string(mut self) -> Bool
```

Check if value is a string.

#### `is_array`

```mojo
def is_array(mut self) -> Bool
```

Check if value is an array.

#### `is_object`

```mojo
def is_object(mut self) -> Bool
```

Check if value is an object.

#### `raw`

```mojo
def raw(self) -> String
```

Get the raw JSON string.

#### `get`

```mojo
def get(self, pointer: String) -> Value
```

Get a value at the given JSON Pointer path.

Only parses the necessary parts of the JSON to reach the target.

Example:
var name = lazy.get("/users/0/name").

Args:

- `pointer`: JSON Pointer path (e.g., "/users/0/name").

#### `get_string`

```mojo
def get_string(self, pointer: String) -> String
```

Get a string value at the given path.

Args:

- `pointer`: JSON Pointer path.

#### `get_int`

```mojo
def get_int(self, pointer: String) -> Int64
```

Get an integer value at the given path.

Args:

- `pointer`: JSON Pointer path.

#### `get_bool`

```mojo
def get_bool(self, pointer: String) -> Bool
```

Get a boolean value at the given path.

Args:

- `pointer`: JSON Pointer path.

#### `parse`

```mojo
def parse(self) -> Value
```

Fully parse the JSON into a Value.

Use this when you need the complete parsed structure.
For accessing specific fields, use get() instead.

## Functions

### `loads_lazy`

```mojo
def loads_lazy(s: String) -> LazyValue
```

Create a lazy JSON value without parsing.

The JSON is only parsed when you access specific values.
This is efficient for large documents where you only need
a few fields.

Example:
var lazy = loads_lazy(huge_json)
var name = lazy.get("/users/0/name")  # Only parses path to name.

Args:

- `s`: JSON string.
