MCPcopy Create free account
hub / github.com/acl-dev/acl / print_value

Function print_value

lib_acl/samples/json/json5/cJSON.cpp:372–403  ·  view source on GitHub ↗

Render a value to text. */

Source from the content-addressed store, hash-verified

370
371/* Render a value to text. */
372static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p)
373{
374 char *out=0;
375 if (!item) return 0;
376 if (p)
377 {
378 switch ((item->type)&255)
379 {
380 case cJSON_NULL: {out=ensure(p,5); if (out) strcpy(out,"null"); break;}
381 case cJSON_False: {out=ensure(p,6); if (out) strcpy(out,"false"); break;}
382 case cJSON_True: {out=ensure(p,5); if (out) strcpy(out,"true"); break;}
383 case cJSON_Number: out=print_number(item,p);break;
384 case cJSON_String: out=print_string(item,p);break;
385 case cJSON_Array: out=print_array(item,depth,fmt,p);break;
386 case cJSON_Object: out=print_object(item,depth,fmt,p);break;
387 }
388 }
389 else
390 {
391 switch ((item->type)&255)
392 {
393 case cJSON_NULL: out=cJSON_strdup("null"); break;
394 case cJSON_False: out=cJSON_strdup("false");break;
395 case cJSON_True: out=cJSON_strdup("true"); break;
396 case cJSON_Number: out=print_number(item,0);break;
397 case cJSON_String: out=print_string(item,0);break;
398 case cJSON_Array: out=print_array(item,depth,fmt,0);break;
399 case cJSON_Object: out=print_object(item,depth,fmt,0);break;
400 }
401 }
402 return out;
403}
404
405/* Build an array from input text. */
406static const char *parse_array(cJSON *item,const char *value)

Callers 5

cJSON_PrintFunction · 0.70
cJSON_PrintUnformattedFunction · 0.70
cJSON_PrintBufferedFunction · 0.70
print_arrayFunction · 0.70
print_objectFunction · 0.70

Calls 6

ensureFunction · 0.85
print_numberFunction · 0.85
print_stringFunction · 0.85
print_arrayFunction · 0.85
print_objectFunction · 0.85
cJSON_strdupFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…