Skip to content
New issue

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

valueint support uint64_t #87

Closed
crazy-william opened this issue Dec 19, 2016 · 1 comment
Closed

valueint support uint64_t #87

crazy-william opened this issue Dec 19, 2016 · 1 comment
Labels

Comments

@crazy-william
Copy link

crazy-william commented Dec 19, 2016

If I want to export or read json number exceeding int, valueint will be overflow. How can I do with this?

Another advice:

typedef struct cJSON
{
    /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
    struct cJSON *next;
    struct cJSON *prev;
    /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
    struct cJSON *child;

    /* The type of the item, as above. */
    int type;

    /* The item's string, if type==cJSON_String */
    char *valuestring;
    /* The item's number, if type==cJSON_Number */
    int valueint;
    /* The item's number, if type==cJSON_Number */
    double valuedouble;

    /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
    char *string;
} cJSON;

And I think "valuestring,valueint,valuedouble" can be in one union.

@FSMaxB
Copy link
Collaborator

FSMaxB commented Dec 19, 2016

Use valuedouble, then you get 53 bits of integer precision on most platforms. You're not the first to suggest the use of a union, changing the cJSON struct is not possible for the current version though, because of compatibility reasons. Version 2 will fix this, see #63.

There's currently no estimated release date of version 2 though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants