| 2154 | } |
| 2155 | |
| 2156 | cJSON *cJSON_CreateNumber(double num) |
| 2157 | { |
| 2158 | cJSON *item = cJSON_New_Item(); |
| 2159 | if(item) |
| 2160 | { |
| 2161 | item->type = cJSON_Number; |
| 2162 | item->valuedouble = num; |
| 2163 | |
| 2164 | /* use saturation in case of overflow */ |
| 2165 | if (num >= INT_MAX) |
| 2166 | { |
| 2167 | item->valueint = INT_MAX; |
| 2168 | } |
| 2169 | else if (num <= INT_MIN) |
| 2170 | { |
| 2171 | item->valueint = INT_MIN; |
| 2172 | } |
| 2173 | else |
| 2174 | { |
| 2175 | item->valueint = (int)num; |
| 2176 | } |
| 2177 | } |
| 2178 | |
| 2179 | return item; |
| 2180 | } |
| 2181 | |
| 2182 | cJSON *cJSON_CreateString(const char *string) |
| 2183 | { |
no test coverage detected