Skip to main content

ToJSON

Converts the ApiPresentation object into the JSON object.

Syntax

expression.ToJSON(bWriteTableStyles);

expression - A variable that represents a ApiPresentation class.

Parameters

NameRequired/OptionalData typeDefaultDescription
bWriteTableStylesOptionalbooleanfalseSpecifies whether to write used table styles to the JSON object (true) or not (false).

Returns

JSON

Example

Convert the presentation object into the JSON object in a presentation.

// How to convert the presentation object to JSON objects.

// Get JSON representations of each slide from the presentation.

const presentation = Api.GetPresentation();
const json = presentation.ToJSON(true);
const presentationFromJSON = Api.FromJSON(json);
const slide = presentationFromJSON.GetSlideByIndex(0);
slide.RemoveAllObjects();

const fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);

const classType = presentationFromJSON.GetClassType();
const docContent = shape.GetDocContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText("Class type = " + classType);
slide.AddObject(shape);