toJson

View as MarkdownOpen in Claude

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

Parameters

None.

Returns

string — JSON-serialized array of section data.

Example

1import { PromptObjectModel } from '@signalwire/sdk';
2
3const pom = new PromptObjectModel();
4pom.addSection('Intro', { body: 'Welcome.' });
5pom.addSection('Rules', { bullets: ['Be nice.', 'Stay on topic.'] });
6
7const json = pom.toJson();
8const restored = PromptObjectModel.fromJson(json);