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

# toJson

> Serialize all sections to a JSON string.

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

[ref-fromsections]: /docs/server-sdks/reference/typescript/agents/pom-builder/from-sections

Serialize all top-level sections to a JSON string. Internally calls
[`toDict()`][ref-todict] and wraps the result in `JSON.stringify()`. Use this
to persist a prompt for later restoration via
[`PomBuilder.fromSections()`][ref-fromsections].

## **Returns**

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

## **Example**

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

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

const json = pom.toJson();
// Persist, send over the wire, etc.
const restored = PomBuilder.fromSections(JSON.parse(json));
```