> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# toJson

> Serialize the model to a JSON string.

[ref-todict]: /docs/server-sdks/reference/typescript/agents/pom-object-model/to-dict

[ref-fromjson]: /docs/server-sdks/reference/typescript/agents/pom-object-model/from-json

Serialize the entire model to a pretty-printed (2-space indent) JSON string.
Internally calls [`toDict()`][ref-todict] and wraps the result in
`JSON.stringify()`. Restore later via [`fromJson()`][ref-fromjson].

## **Parameters**

None.

## **Returns**

`string` -- JSON-serialized array of section data.

## **Example**

```typescript {7}
import { PromptObjectModel } from '@signalwire/sdk';

const pom = new PromptObjectModel();
pom.addSection('Intro', { body: 'Welcome.' });
pom.addSection('Rules', { bullets: ['Be nice.', 'Stay on topic.'] });

const json = pom.toJson();
const restored = PromptObjectModel.fromJson(json);
```