Skip to main content

ToJSON

Converts the ApiSlide object into the JSON object.

Syntax

expression.ToJSON(bWriteLayout, bWriteMaster, bWriteAllMasLayouts, bWriteTableStyles);

expression - A variable that represents a ApiSlide class.

Parameters

NameRequired/OptionalData typeDefaultDescription
bWriteLayoutOptionalbooleanfalseSpecifies if the slide layout will be written to the JSON object or not.
bWriteMasterOptionalbooleanfalseSpecifies if the slide master will be written to the JSON object or not (bWriteMaster is false if bWriteLayout === false).
bWriteAllMasLayoutsOptionalbooleanfalseSpecifies if all child layouts from the slide master will be written to the JSON object or not.
bWriteTableStylesOptionalbooleanfalseSpecifies whether to write used table styles to the JSON object (true) or not (false).

Returns

JSON

Example

This example converts the ApiSlide object into the JSON object.

// How to convert a slide object to a JSON object.

// Get a slide by its index and convert it to JSON.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const json = slide.ToJSON(true, true, true, true);
const slideFromJSON = Api.FromJSON(json);
presentation.AddSlide(slideFromJSON);
const classType = slideFromJSON.GetClassType();

const fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const drawing = Api.CreateShape("flowChartMagneticTape", 300 * 36000, 130 * 36000, fill, stroke);
drawing.SetPosition(608400, 1267200);
drawing.SetSize(300 * 36000, 130 * 36000);
slide.AddObject(drawing);

const docContent = drawing.GetDocContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText("Class type = " + classType);