AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

toJSON

介绍

toJSON()NavEdge 实例方法,用于将 NavEdge 对象转换为 JSON 格式的字符串。

语法

navEdgeInstance.toJSON()

返回值

返回一个 JSON 格式的字符串。

示例

var navEdge = new NavEdge({
  from: "A",
  to: "B",
  weight: 2
});

var jsonString = navEdge.toJSON();

console.log(jsonString);
// 输出: '{"from":"A","to":"B","weight":2}'

备注

NavEdge 实例所包含的属性将会被转换成 JSON 格式,并返回一个 JSON 格式的字符串。

该方法不支持传参。如果需要转换带参数的对象,请使用 JSON.stringify() 方法。

错误类型

如果执行 toJSON() 方法时,对象出现异常或者出现无法转换为 JSON 的属性类型,则会返回一个错误类型。