该方法用于将CohesionBehavior对象转换为JSON格式的字符串。
cohesionBehavior.toJSON();
返回一个JSON格式的字符串。
var cb = new CohesionBehavior();
//设置属性
cb.setId("CB0001");
cb.setName("行为一致性控制器");
cb.setVersion("1.0");
//将CohesionBehavior对象转换为JSON格式的字符串
var jsonStr = cb.toJSON();
console.log(jsonStr);
输出结果为:
{
"id": "CB0001",
"name": "行为一致性控制器",
"version": "1.0"
}