MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _JsonEncoder_Node

Function _JsonEncoder_Node

src/util/json_encoder.c:43–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43static sds _JsonEncoder_Node(const Node *n, sds s) {
44 s = sdscatfmt(s, "\"id\": %U", ENTITY_GET_ID(n));
45 s = sdscat(s, ", \"labels\": [");
46 // Retrieve node labels
47 uint label_count;
48 GraphContext *gc = QueryCtx_GetGraphCtx();
49 NODE_GET_LABELS(gc->g, n, label_count);
50 for(uint i = 0; i < label_count; i ++) {
51 Schema *schema = GraphContext_GetSchemaByID(gc, labels[i], SCHEMA_NODE);
52 ASSERT(schema);
53 const char *label = Schema_GetName(schema);
54 ASSERT(label);
55 s = sdscatfmt(s, "\"%s\"", label);
56 if(i != label_count - 1) s = sdscat(s, ", ");
57 }
58 s = sdscat(s, "], ");
59 s = _JsonEncoder_Properties((const GraphEntity *)n, s);
60 return s;
61}
62
63static sds _JsonEncoder_Edge(Edge *e, sds s) {
64 s = sdscatfmt(s, "\"id\": %U", ENTITY_GET_ID(e));

Callers 2

_JsonEncoder_EdgeFunction · 0.85
_JsonEncoder_GraphEntityFunction · 0.85

Calls 6

sdscatfmtFunction · 0.85
sdscatFunction · 0.85
QueryCtx_GetGraphCtxFunction · 0.85
Schema_GetNameFunction · 0.85
_JsonEncoder_PropertiesFunction · 0.85

Tested by

no test coverage detected