toJSON
是一个将 RightShoulderFuzzySet 转换为 JSON 字符串的函数。
fuzzySet.toJSON()
返回包含 RightShoulderFuzzySet 对象属性的 JSON 字符串。
const FuzzySet = require('yuka');
const set = new FuzzySet.RightShoulderFuzzySet(20, 40, 60);
const json = set.toJSON();
console.log(json);
// Output: '{"type":"RightShoulderFuzzySet","left":20,"right":40,"height":60}'
type
:模糊集类型,固定值为 "RightShoulderFuzzySet"
。left
:模糊集左端点。right
:模糊集右端点。height
:模糊集高度。如果 toJSON
函数调用失败,将抛出一个异常。
JSON 字符串可以传输和存储数据。要将 JSON 字符串转换回 RightShoulderFuzzySet 对象,请使用 RightShoulderFuzzySet.fromJSON(json)
函数。