cJSON
cJSON copied to clipboard
Large Numbers as strings
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 intoitem->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...)
I went an wrote up what I had in mind & got the tests working as well. https://github.com/DaveGamble/cJSON/pull/580
@Alanscut what do you think about this approach?