Issue #1
resolved
Parse Large Interger Error
Here is a sample.
char buffer[] = "{\"val\": 429496729006}"; const nx_json *json = nx_json_parse_utf8(buffer); std::cout << "intVal: " << json->child->int_value << std::endl; std::cout << "dblVal: " << json->child->dbl_value << std::endl; nx_json_free(json);
And the output is
intVal: 2147483647 dblVal: 2.14748e+009
Comments (7)
-
Yaroslav Stavnichiy repo owner
-
Yu Denzel reporter
Whether it will be Ok to use int64/uint64 to store the large integer?
Or treat it as a double(This is the way implemented in cJson)?
-
Yaroslav Stavnichiy repo owner
You can replace
longwithlong longtype in header and usestrtollinstead ofstrtolinparse_value(). -
Yu Denzel reporter
Would it be ok to send a pull request to the rep?
-
Yaroslav Stavnichiy repo owner
I think for repo we need some more versatile solution. This was just a quick workaround.
-
Yaroslav Stavnichiy repo owner
- changed status to resolved
Fixed issue
#1: integer overflow triggers parse error. Integer range is also extended to long long (64 bits).→ <<cset afaf7f999a95>>
-
Yaroslav Stavnichiy repo owner
I've just committed the fix. Integer overflow now triggers parse error. Integer range has also been extended to
long longtype. - Log in to comment
Integer overflow. What do you think would be appropriate behavior in this case?