# JSONValue.encode(to:)

- **Module:** JSONValue
- **Package:** LibTmuxMCP
- **Language:** Swift
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-swift/blob/254f8b2be7eb60cacc3ffcb3ea8e456784f582df/Sources/LibTmuxMCP/JSONValue.swift#L39
- **Page:** https://libtmux.org/en/swift/latest/mcp/reference/jsonvalue-encode(to-)/

```
JSONValue.encode(to:)(to: any Encoder) -> ()
```

Encodes this value into the given encoder.

If the value fails to encode anything, `encoder` will encode an empty
keyed container in its place.

This function throws an error if any values are invalid for the given
encoder's format.

- Parameter encoder: The encoder to write data to.
