MCPcopy Create free account
hub / github.com/binbyu/Reader / cJSON_CreateNumber

Function cJSON_CreateNumber

opensrc/cjson/cJSON.c:2292–2316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2290}
2291
2292CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num)
2293{
2294 cJSON *item = cJSON_New_Item(&global_hooks);
2295 if(item)
2296 {
2297 item->type = cJSON_Number;
2298 item->valuedouble = num;
2299
2300 /* use saturation in case of overflow */
2301 if (num >= INT_MAX)
2302 {
2303 item->valueint = INT_MAX;
2304 }
2305 else if (num <= INT_MIN)
2306 {
2307 item->valueint = INT_MIN;
2308 }
2309 else
2310 {
2311 item->valueint = (int)num;
2312 }
2313 }
2314
2315 return item;
2316}
2317
2318CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string)
2319{

Callers 6

json_header_tMethod · 0.85
json_item_tMethod · 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