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

Function _JsonEncoder_Map

src/util/json_encoder.c:166–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166static sds _JsonEncoder_Map(SIValue map, sds s) {
167 ASSERT(SI_TYPE(map) & T_MAP);
168
169 // "{" marks the beginning of a map
170 s = sdscat(s, "{");
171
172 uint key_count = Map_KeyCount(map);
173 for(uint i = 0; i < key_count; i ++) {
174 Pair p = map.map[i];
175 // write the next key/value pair
176 s = _JsonEncoder_String(p.key, s);
177 s = sdscat(s, ": ");
178 s = _JsonEncoder_SIValue(p.val, s);
179 // if this is not the last element, add ", "
180 if(i != key_count - 1) s = sdscat(s, ", ");
181 }
182
183 // "}" marks the end of a map
184 s = sdscat(s, "}");
185 return s;
186}
187
188sds _JsonEncoder_SIValue(SIValue v, sds s) {
189 switch(v.type) {

Callers 1

_JsonEncoder_SIValueFunction · 0.85

Calls 4

sdscatFunction · 0.85
Map_KeyCountFunction · 0.85
_JsonEncoder_StringFunction · 0.85
_JsonEncoder_SIValueFunction · 0.85

Tested by

no test coverage detected