ibireme / yyjson

The fastest JSON library in C
https://ibireme.github.io/yyjson/doc/doxygen/html/
MIT License
3.04k stars 262 forks source link

About number processing and obtaining #108

Closed CarterLi closed 1 year ago

CarterLi commented 1 year ago

Currently we have yyjson_is_num, but not yyjson_get_num. Instead, we have yyjson_get_{uint|sint|int|real}, which is problematic because an positive integer is both uint sint int real as JSON has the only number type: number. In this case, we have to test for number type always because we can't force users write addition .0.

I'd like to have a yyjson_get_num, which returns double regardless of what the number type is.

ibireme commented 1 year ago

I agree. This function can simplify the calls for people who only need double numbers. I'll add it later.

ibireme commented 1 year ago

Added: https://github.com/ibireme/yyjson/commit/82b30d913c084aab2c7fe1dad91d2f0bbcada83a