Skip to main content

ToJSON

Converts the ApiStyle object into the JSON object.

Syntax

expression.ToJSON(bWriteNumberings);

expression - A variable that represents a ApiStyle class.

Parameters

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

Returns

JSON

Example

This example converts the ApiStyle object into the JSON object.

// How to get a JSON from the style object.

// Convert the style to json and add it to the document.

let doc = Api.GetDocument();
let tableStyle = doc.GetStyle("Bordered");
let json = tableStyle.ToJSON(false);
let styleFromJSON = Api.FromJSON(json);
styleFromJSON.SetName("My Custom Style");
let table = Api.CreateTable(2, 2);
table.SetWidth("percent", 100);
table.SetStyle(styleFromJSON);
doc.Push(table);