Skip to main content

ToJSON

Converts the ApiParaPr object into the JSON object.

Syntax

expression.ToJSON(bWriteStyles);

expression - A variable that represents a ApiParaPr class.

Parameters

NameRequired/OptionalData typeDefaultDescription
bWriteStylesRequiredbooleanSpecifies if the used styles will be written to the JSON object or not.

Returns

JSON

Example

This example converts the ApiParaPr object into the JSON object.

// How to get a JSON from the paragraph properties.

// Convert the paragraph properties to json and add it to the paragraph.

let doc = Api.GetDocument();
let myStyle = doc.CreateStyle("My document style");
let paraPr = myStyle.GetParaPr();
paraPr.SetLeftBorder("single", 24, 0, 0, 255, 0);
let json = paraPr.ToJSON(true);
let paraPrFromJSON = Api.FromJSON(json);
let type = paraPrFromJSON.GetClassType();
let paragraph = doc.GetElement(0);
paragraph.AddText("Class type = " + type);