Skip to main content

FromJSON

Converts the specified JSON object into the Document Builder object of the corresponding type.

Syntax

expression.FromJSON(message);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
messageRequiredJSONThe JSON object to convert.

Returns

object

Example

Restore a paragraph from its JSON representation and insert it into a document.

// How do I recreate a paragraph from a JSON object in a document?

// Save a paragraph as JSON and then rebuild it as a bold paragraph in a document.

let paragraph = Api.CreateParagraph();
paragraph.AddText("This is a new paragraph");
let json = paragraph.ToJSON(false, true);
let paragraphFromJSON = Api.FromJSON(json);
paragraphFromJSON.SetBold(true);
Api.GetDocument().AddElement(0, paragraphFromJSON);