跳到主要内容

ToJSON

Converts the ApiRange object into the JSON object.

Syntax

expression.ToJSON(bWriteNumberings, bWriteStyles);

expression - A variable that represents a ApiRange class.

Parameters

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

Returns

JSON

Example

This example converts the ApiRange object into the JSON object.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let range = Api.CreateRange(paragraph, 0, 9);
range.SetBold(true);
let json = range.ToJSON(false, true);
let rangeFromJSON = Api.FromJSON(json);
doc.Push(rangeFromJSON[0]);