ToJSON
Converts the ApiRange object into the JSON object.
Syntax
expression.ToJSON(bWriteNumberings, bWriteStyles);
expression
- A variable that represents a ApiRange class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
bWriteNumberings | Required | boolean | Specifies if the used numberings will be written to the JSON object or not. | |
bWriteStyles | Required | boolean | Specifies 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.
- Code
- Result
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]);