# json.cpu.simdjson_ffi

> A module of json_mlake's API.

## Structs

### `SimdjsonTape`

```mojo
struct SimdjsonTape
```

The tape-building entry points over the calling thread's parser.

The symbols are resolved once per process and no parser is created
or destroyed per parse, so a small document pays almost nothing
beyond simdjson's own work.

Implements: `Movable`

#### `__init__`

```mojo
def __init__(out self)
```

#### `parse_to_document`

```mojo
def parse_to_document(self, json: String) -> Document
```

Parse `json` and lay it out as a tape in one FFI call.

Strings and keys come back unescaped in one arena that becomes the
document's byte source, so no string is allocated on its own.

### `SimdjsonFFI`

```mojo
struct SimdjsonFFI
```

Low-level simdjson FFI bindings. All pointer args are passed as Int.

Implements: `Movable`

#### `__init__`

```mojo
def __init__(out self, lib_path: String = "")
```

Initialize by loading the simdjson wrapper library.

Args:

- `lib_path`: Path to the library. If empty, `_dlopen.open_library`
          searches $CONDA_PREFIX/lib, next to the executable and
          its ../lib, then the binary's rpath, and raises an
          Error saying to set CONDA_PREFIX if none has it.

#### `destroy`

```mojo
def destroy(mut self)
```

Clean up the parser. Call this explicitly when done.

#### `parse`

```mojo
def parse(mut self, json: String) -> Int
```

Parse JSON and return root value handle.

#### `get_type`

```mojo
def get_type(self, value: Int) -> Int
```

Get the type of a value.

#### `get_bool`

```mojo
def get_bool(self, value: Int) -> Bool
```

Get value as boolean.

#### `get_int`

```mojo
def get_int(self, value: Int) -> Int64
```

Get value as int64.

#### `get_uint`

```mojo
def get_uint(self, value: Int) -> UInt64
```

Get value as uint64.

#### `get_float`

```mojo
def get_float(self, value: Int) -> Float64
```

Get value as double.

#### `get_string`

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

Get value as string - uses unsafe_from_utf8 for zero-copy.

#### `free_value`

```mojo
def free_value(self, value: Int)
```

Free a value handle.

#### `array_count`

```mojo
def array_count(self, value: Int) -> Int
```

Get array element count.

#### `array_begin`

```mojo
def array_begin(self, value: Int) -> Int
```

Start iterating over array.

#### `array_iter_done`

```mojo
def array_iter_done(self, iter: Int) -> Bool
```

Check if array iteration is done.

#### `array_iter_get`

```mojo
def array_iter_get(self, iter: Int) -> Int
```

Get current array element.

#### `array_iter_next`

```mojo
def array_iter_next(self, iter: Int)
```

Move to next array element.

#### `array_iter_free`

```mojo
def array_iter_free(self, iter: Int)
```

Free array iterator.

#### `object_count`

```mojo
def object_count(self, value: Int) -> Int
```

Get object key count.

#### `object_begin`

```mojo
def object_begin(self, value: Int) -> Int
```

Start iterating over object.

#### `object_iter_done`

```mojo
def object_iter_done(self, iter: Int) -> Bool
```

Check if object iteration is done.

#### `object_iter_get_key`

```mojo
def object_iter_get_key(self, iter: Int) -> String
```

Get current object key - uses unsafe_from_utf8 for zero-copy.

#### `object_iter_get_value`

```mojo
def object_iter_get_value(self, iter: Int) -> Int
```

Get current object value.

#### `object_iter_next`

```mojo
def object_iter_next(self, iter: Int)
```

Move to next object key-value pair.

#### `object_iter_free`

```mojo
def object_iter_free(self, iter: Int)
```

Free object iterator.

## Aliases

### `SIMDJSON_OK`

```mojo
comptime SIMDJSON_OK = Int(0)
```

### `SIMDJSON_ERROR_INVALID_JSON`

```mojo
comptime SIMDJSON_ERROR_INVALID_JSON = Int(1)
```

### `SIMDJSON_ERROR_CAPACITY`

```mojo
comptime SIMDJSON_ERROR_CAPACITY = Int(2)
```

### `SIMDJSON_ERROR_UTF8`

```mojo
comptime SIMDJSON_ERROR_UTF8 = Int(3)
```

### `SIMDJSON_ERROR_OTHER`

```mojo
comptime SIMDJSON_ERROR_OTHER = Int(99)
```

### `SIMDJSON_TYPE_NULL`

```mojo
comptime SIMDJSON_TYPE_NULL = Int(0)
```

### `SIMDJSON_TYPE_BOOL`

```mojo
comptime SIMDJSON_TYPE_BOOL = Int(1)
```

### `SIMDJSON_TYPE_INT64`

```mojo
comptime SIMDJSON_TYPE_INT64 = Int(2)
```

### `SIMDJSON_TYPE_UINT64`

```mojo
comptime SIMDJSON_TYPE_UINT64 = Int(3)
```

### `SIMDJSON_TYPE_DOUBLE`

```mojo
comptime SIMDJSON_TYPE_DOUBLE = Int(4)
```

### `SIMDJSON_TYPE_STRING`

```mojo
comptime SIMDJSON_TYPE_STRING = Int(5)
```

### `SIMDJSON_TYPE_ARRAY`

```mojo
comptime SIMDJSON_TYPE_ARRAY = Int(6)
```

### `SIMDJSON_TYPE_OBJECT`

```mojo
comptime SIMDJSON_TYPE_OBJECT = Int(7)
```
