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

Large Numbers as strings #579

Open
schmidtw opened this issue May 12, 2021 · 2 comments
Open

Large Numbers as strings #579

schmidtw opened this issue May 12, 2021 · 2 comments

Comments

@schmidtw
Copy link

I wanted to see if there would be any interest in accepting a patch where large numbers (like even larger than 64bit numbers) would be handled as a string in addition to a native type, or if large enough, just a string.

Why strings?

  • While generally not ideal for numbers, it's pretty easy to represent a 64 byte number as a string. The code that needs to handle the crazy number can deal with it vs. cJSON needing to.
  • Allows software that want 64bit number support to add it & deal with it outside cJSON while allowing cJSON to stay C89.
  • It looks like it would be pretty easy to add to the decoder (like a cJSON_strdup() call into item->valuestring)
  • I don't want to change code away from this library that is really solid just because I need to pass large numbers in a few specialized payloads (& that can't string encode them...)
@schmidtw
Copy link
Author

I went an wrote up what I had in mind & got the tests working as well.
#580

@schmidtw
Copy link
Author

@Alanscut what do you think about this approach?

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

No branches or pull requests

1 participant