ToJSON
将 ApiParaPr 对象转换为 JSON 对象。
语法
expression.ToJSON(bWriteStyles);
expression - 表示 ApiParaPr 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| bWriteStyles | 必需 | boolean | 指定使用的样式是否将写入 JSON 对象。 |
返回值
JSON
示例
在文档中将段落属性序列化为 JSON 对象。
// How do I export paragraph formatting settings as JSON in a document?
// Restore paragraph properties from a JSON representation and verify the class type in a document.
let doc = Api.GetDocument();
let myStyle = doc.CreateStyle("My document style");
let paraPr = myStyle.GetParaPr();
paraPr.SetLeftBorder("single", 24, 0, 0, 255, 0);
let json = paraPr.ToJSON(true);
let paraPrFromJSON = Api.FromJSON(json);
let type = paraPrFromJSON.GetClassType();
let paragraph = doc.GetElement(0);
paragraph.AddText("Class type = " + type);