MCPcopy Create free account
hub / github.com/Netis/cloud-probe / cJSON_CreateNumber

Function cJSON_CreateNumber

cpworker/src/cJSON/cJSON.c:2452–2476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2450}
2451
2452CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
2453{
2454 cJSON *item = cJSON_New_Item(&global_hooks);
2455 if(item)
2456 {
2457 item->type = cJSON_Number;
2458 item->valuedouble = num;
2459
2460 /* use saturation in case of overflow */
2461 if (num >= INT_MAX)
2462 {
2463 item->valueint = INT_MAX;
2464 }
2465 else if (num <= (double)INT_MIN)
2466 {
2467 item->valueint = INT_MIN;
2468 }
2469 else
2470 {
2471 item->valueint = (int)num;
2472 }
2473 }
2474
2475 return item;
2476}
2477
2478CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
2479{

Callers 8

bytes_stats_json_dumpFunction · 0.85
packets_stats_json_dumpFunction · 0.85
cJSON_AddNumberToObjectFunction · 0.85
cJSON_CreateIntArrayFunction · 0.85
cJSON_CreateFloatArrayFunction · 0.85
cJSON_CreateDoubleArrayFunction · 0.85

Calls 1

cJSON_New_ItemFunction · 0.85

Tested by

no test coverage detected