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

Function _JsonEncoder_SIValue

src/util/json_encoder.c:188–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186}
187
188sds _JsonEncoder_SIValue(SIValue v, sds s) {
189 switch(v.type) {
190 case T_STRING:
191 s = _JsonEncoder_String(v, s);
192 break;
193 case T_INT64:
194 s = sdscatfmt(s, "%I", v.longval);
195 break;
196 case T_BOOL:
197 if(v.longval) s = sdscat(s, "true");
198 else s = sdscat(s, "false");
199 break;
200 case T_DOUBLE:
201 s = sdscatprintf(s, "%.15g", v.doubleval);
202 break;
203 case T_NODE:
204 s = _JsonEncoder_GraphEntity(v.ptrval, s, GETYPE_NODE);
205 break;
206 case T_EDGE:
207 s = _JsonEncoder_GraphEntity(v.ptrval, s, GETYPE_EDGE);
208 break;
209 case T_ARRAY:
210 s = _JsonEncoder_Array(v, s);
211 break;
212 case T_MAP:
213 s = _JsonEncoder_Map(v, s);
214 break;
215 case T_PATH:
216 s = _JsonEncoder_Path(v, s);
217 break;
218 case T_NULL:
219 s = sdscat(s, "null");
220 break;
221 case T_POINT:
222 s = _JsonEncoder_Point(v, s);
223 break;
224 default:
225 // unrecognized type
226 ErrorCtx_RaiseRuntimeException("JSON encoder encountered unrecognized type: %d\n", v.type);
227 ASSERT(false);
228 break;
229 }
230 return s;
231}
232
233char *JsonEncoder_SIValue(SIValue v) {
234 // Create an empty sds string.

Callers 4

_JsonEncoder_PropertiesFunction · 0.85
_JsonEncoder_ArrayFunction · 0.85
_JsonEncoder_MapFunction · 0.85
JsonEncoder_SIValueFunction · 0.85

Calls 10

_JsonEncoder_StringFunction · 0.85
sdscatfmtFunction · 0.85
sdscatFunction · 0.85
sdscatprintfFunction · 0.85
_JsonEncoder_GraphEntityFunction · 0.85
_JsonEncoder_ArrayFunction · 0.85
_JsonEncoder_MapFunction · 0.85
_JsonEncoder_PathFunction · 0.85
_JsonEncoder_PointFunction · 0.85

Tested by

no test coverage detected