跳到主要内容

ToJSON

将 ApiStyle 对象转换为 JSON 对象。

语法

expression.ToJSON(bWriteNumberings);

expression - 表示 ApiStyle 类的变量。

参数

名称必需/可选数据类型默认值描述
bWriteNumberings必需boolean指定使用的编号是否将写入 JSON 对象。

返回值

JSON

示例

此示例将 ApiStyle 对象转换为 JSON 对象。

// How to get a JSON from the style object.

// Convert the style to json and add it to the document.

let doc = Api.GetDocument();
let tableStyle = doc.GetStyle("Bordered");
let json = tableStyle.ToJSON(false);
let styleFromJSON = Api.FromJSON(json);
styleFromJSON.SetName("My Custom Style");
let table = Api.CreateTable(2, 2);
table.SetWidth("percent", 100);
table.SetStyle(styleFromJSON);
doc.Push(table);