We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It would be very useful to always provide valuestring no matter what data type the value is. Example use cases:
valuestring
It would extend the possibilities of cJSON while preserving C89 compatibility.
cJSON
Code demonstration:
#include <stdio.h> #include <stdlib.h> #include <cjson/cJSON.h> #define JSON_RAW "{\"number\":3000000000,\"ulonglong\":\"10000000000000000000\",\"hugeint\":\"1000000000000000000000000000000\"}" int main() { cJSON *overint32, *ulonglong; cJSON *json = cJSON_Parse(JSON_RAW); overint32 = cJSON_GetObjectItemCaseSensitive(json, "number"); if (cJSON_IsNumber(overint32)) { printf("IsNumber. valueint=%d, valuedouble=%f, valuestring=\"%s\"\n", overint32->valueint, overint32->valuedouble, overint32->valuestring); } ulonglong = cJSON_GetObjectItemCaseSensitive(json, "ulonglong"); if (cJSON_IsString(ulonglong)) { char *endptr; unsigned long long int ull = strtoull(ulonglong->valuestring, &endptr, 10); printf("IsString. valuestring=\"%s\", unsigned long long int = %llu\n", ulonglong->valuestring, ull); } /* typedef struct __uint256_t { char arr[32]; } __uint256_t; hugeint = cJSON_GetObjectItemCaseSensitive(json, "hugeint"); // Custom integral number interpreter __uint256_t value = custom_strtoint(hugeint->valuestring); */ cJSON_Delete(json); return 0; }
This issue aims to cover the following ones, which include more details and ideas:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Proposal
It would be very useful to always provide
valuestring
no matter what data type the value is.Example use cases:
It would extend the possibilities of
cJSON
while preserving C89 compatibility.Code demonstration:
Related issues
This issue aims to cover the following ones, which include more details and ideas:
The text was updated successfully, but these errors were encountered: