fromJson

View as MarkdownOpen in Claude

Static factory that reconstructs a PromptObjectModel from JSON data. Use this to restore a model serialized via toJson().

Parameters

jsonData
string | unknownRequired

Either a JSON string or an already-parsed array of section data objects. A string is parsed with JSON.parse(); anything else is used directly.

Returns

PromptObjectModel — A new model populated from the supplied data.

Example

import { PromptObjectModel } from '@signalwire/sdk';
const data = [
{ title: 'Intro', body: 'Welcome.' },
{ title: 'Rules', bullets: ['Be nice.', 'Stay on topic.'] },
];
const pom = PromptObjectModel.fromJson(data);
console.log(pom.renderMarkdown());