| 107 | } |
| 108 | |
| 109 | static sds _JsonEncoder_Path(SIValue p, sds s) { |
| 110 | // open path with "[" |
| 111 | s = sdscat(s, "["); |
| 112 | |
| 113 | size_t nodeCount = SIPath_NodeCount(p); |
| 114 | for(size_t i = 0; i < nodeCount - 1; i ++) { |
| 115 | // write the next value |
| 116 | SIValue node = SIPath_GetNode(p, i); |
| 117 | s = _JsonEncoder_GraphEntity((GraphEntity *)node.ptrval, s, GETYPE_NODE); |
| 118 | s = sdscat(s, ", "); |
| 119 | SIValue edge = SIPath_GetRelationship(p, i); |
| 120 | s = _JsonEncoder_GraphEntity((GraphEntity *)edge.ptrval, s, GETYPE_EDGE); |
| 121 | s = sdscat(s, ", "); |
| 122 | } |
| 123 | // Handle last node. |
| 124 | if(nodeCount > 0) { |
| 125 | SIValue node = SIPath_GetNode(p, nodeCount - 1); |
| 126 | s = _JsonEncoder_GraphEntity((GraphEntity *)node.ptrval, s, GETYPE_NODE); |
| 127 | } |
| 128 | |
| 129 | // close array with "]" |
| 130 | s = sdscat(s, "]"); |
| 131 | return s; |
| 132 | } |
| 133 | |
| 134 | static sds _JsonEncoder_Point(SIValue point, sds s) { |
| 135 | ASSERT(SI_TYPE(point) & T_POINT); |
no test coverage detected