You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for this great library. While using it, I encounterd an error with overflowed integer. I was able to reproduce this on json-data.cpp with a large integer.
* limitations under the License.
*/
#include <iostream>
#include "xpack/json.h"
#include <string>
using namespace std;
struct Example {
string type;
xpack::JsonData data;
XPACK(O(type, data));
};
struct Range {
int min;
int max;
XPACK(O(min, max));
};
struct User {
int id;
string name;
XPACK(O(id, name));
};
static void test(const std::string &data) {
Example e;
xpack::json::decode(data, e);
if (e.type == "range") {
Range r;
e.data.Get(r);
} else if (e.type == "user") {
User u;
e.data.Get(u);
cout << u.id << endl;
} else {
}
}
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
string s1 = "{\"type\":\"range\", \"data\":{\"min\":12, \"max\":33}}";
string s2 = "{\"type\":\"user\", \"data\":{\"id\":123344343434343435, \"name\":\"xpack\"}}";
test(s1);
test(s2);
return 0;
}
With a large number in the id of s2, no error was reported (I tried with a larger number and an error indicting not integer is given, which I think should be the correct behavior), but the output is -545967093.
I'm using the latest version of the library on Ubuntu 20.04LTS.
The text was updated successfully, but these errors were encountered:
Thanks for your feedback.
All integers are currently parsed as int64 and then static cast to the target type.
Let me think about how to deal with this better.
Hello,
Thanks for this great library. While using it, I encounterd an error with overflowed integer. I was able to reproduce this on
json-data.cpp
with a large integer.With a large number in the
id
ofs2
, no error was reported (I tried with a larger number and an error indicting not integer is given, which I think should be the correct behavior), but the output is-545967093
.I'm using the latest version of the library on Ubuntu 20.04LTS.
The text was updated successfully, but these errors were encountered: