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

Add long values support #421

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add long values support #421

wants to merge 2 commits into from

Conversation

xdars
Copy link

@xdars xdars commented Jan 13, 2020

During working with Telegram Bot API with cJSON library for parsing values, I've faced an issue. The issue is this: I was unable to get identifier value from response - -1001182111522 - obviously, according to cJSON parse_number function, such value was never going to be stored in item->valueint. Sure, let it go - but why not try to store the value anyways, but as long?

xdars added 2 commits January 13, 2020 15:53
Some APIs like Telegram Bot API return responses with values that cannot be accepted with simple valueint. parse_number() function doesn't actually accept numbers larger than INT_MAX/INT_MIN - if the number is one of those (i.e larger than INT_MAX - integer overflow), the result of "item->valueint" will be INT_MAX. In case overflow, let it try storing the value anyways.
Some APIs like Telegram Bot API return responses with values that cannot be accepted with simple valueint. parse_number() function doesn't actually accept numbers larger than INT_MAX/INT_MIN - if the number is one of those (i.e larger than INT_MAX - integer overflow), the result of "item->valueint" will be INT_MAX. In case overflow, let it try storing the value anyways.
@xdars xdars changed the title Unable to store long value in JSON response Add long values support Jan 13, 2020
@xdars xdars requested a review from Alanscut January 17, 2020 19:53
@Alanscut
Copy link
Collaborator

I'm considering changing it with c99 standard, so it will change to long long int

@xdars
Copy link
Author

xdars commented Jan 18, 2020

In case you're going to add long integer values support, I guess this request can be closed?

@Alanscut
Copy link
Collaborator

Anyway thanks your contribution, I hope to fix this issue once and for all, so you could close it or leave it for discussion.

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

Successfully merging this pull request may close these issues.

2 participants