# JsonSerializer

`import { JsonSerializer } from "destack:json";`

JSON encoder.

```ds title="JsonSerializer"
export class JsonSerializer {
    Error = JsonError;
    serializeNull(): Result<void, JsonError>;
    serializeUndefined(): Result<void, JsonError>;
    serializeBoolean(value: boolean): Result<void, JsonError>;
    serializeNumber(value: float64): Result<void, JsonError>;
    serializeString(value: string): Result<void, JsonError>;
    serializeArray<T: Serialize<this>>(value: readonly T[]): Result<void, JsonError>;
    serializeField<T: Serialize<this>>(key: string, value: &'b readonly T): Result<void, JsonError>;
}
```

[language/library/src/json/codec.ds:9:54](https://github.com/destack-sh/destack/blob/main/language/library/src/json/codec.ds#L9-L54)

## Members

### `Error = JsonError`

The encoding error type.

### `serializeNull(): Result<void, JsonError>`

Serialize a null value.

### `serializeUndefined(): Result<void, JsonError>`

Serialize an undefined value.

### `serializeBoolean(value: boolean): Result<void, JsonError>`

Serialize a boolean value.

### `serializeNumber(value: float64): Result<void, JsonError>`

Serialize a number value.

### `serializeString(value: string): Result<void, JsonError>`

Serialize a string value.

### `serializeArray<T: Serialize<this>>(value: readonly T[]): Result<void, JsonError>`

Serialize an array value.

### `serializeField<T: Serialize<this>>(key: string, value: &'b readonly T): Result<void, JsonError>`

Serialize an object field.
