ToJSON

function ToJSON(
  bWriteDefaultTextPr: boolean = null,
  bWriteDefaultParaPr: boolean = null,
  bWriteTheme: boolean = null,
  bWriteSectionPr: boolean = null,
  bWriteNumberings: boolean = null,
  bWriteStyles: boolean = null,
): JSON

Description

Converts the ApiDocument object into the JSON object.

Parameters

bWriteDefaultTextPrbooleandefault: null

Specifies if the default text properties will be written to the JSON object or not.

bWriteDefaultParaPrbooleandefault: null

Specifies if the default paragraph properties will be written to the JSON object or not.

bWriteThemebooleandefault: null

Specifies if the document theme will be written to the JSON object or not.

bWriteSectionPrbooleandefault: null

Specifies if the document section properties will be written to the JSON object or not.

bWriteNumberingsbooleandefault: null

Specifies if the document numberings will be written to the JSON object or not.

bWriteStylesbooleandefault: null

Specifies if the document styles will be written to the JSON object or not.

Returns

JSON

Overloads

ToJSON(bWriteNumberings, bWriteStyles)

Converts the ApiDocumentContent object into the JSON object.

Try It

var oDocument = Api.GetDocument();
var json = oDocument.ToJSON(true, true, true, true, true, true);
var oDocumentFromJSON = Api.FromJSON(json);
var oParagraph = oDocumentFromJSON[0];
var oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 213, 191), 0);
var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000);
var oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 5400000);
var oStroke = Api.CreateStroke(0, Api.CreateNoFill());
var oDrawing1 = Api.CreateShape("rect", 3212465, 963295, oFill, oStroke);
oParagraph.AddDrawing(oDrawing1);
var oDrawing2 = Api.CreateShape("wave", 3212465, 963295, oFill, oStroke);
oParagraph.AddDrawing(oDrawing2);
var aDrawings = oDocumentFromJSON[0].GetAllShapes();
oParagraph = oDocument.GetElement(0);
oParagraph.AddDrawing(aDrawings[0]);
oParagraph.AddLineBreak();
oParagraph.AddText("This is the first shape from the JSON document.");

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).