dropbox / json11

A tiny JSON library for C++11.
MIT License
2.55k stars 613 forks source link

Support int64 #61

Closed skifire1983 closed 8 years ago

smarx commented 8 years ago

Automated message from Dropbox CLA bot

@skifire1983, it looks like you've already signed the Dropbox CLA. Thanks!

j4cbo commented 8 years ago

Thanks! This is a reasonable call in some use cases, but not something we want to merge into master for the reasons here: https://github.com/dropbox/json11/blob/master/json11.hpp#L16-L27

taozhijiang commented 8 years ago

I did this before, I believe @skifire1983 implement may have some problem as these test cases:

const string str_it2 = R"({"int_max":2147483647,"int_min":-2147483648,"uint_max":4294967295, "uint_min":0, i64_max":9223372036854775807,"i64_min":-9223372036854775808,"ui64_max":18446744073709551615, "ui_64min":0 })"; auto json_uit = Json::parse(str_it2, err_it); std::cout << "ORIGIN:" << str_it2 << std::endl; string str_it2_ret; json_uit.dump(str_it2_ret); std::cout << "DUMP:" << str_it2_ret << std::endl;

assert(json_uit["int_max"].int64_value() == INT_MAX);
assert(json_uit["int_min"].int64_value() == INT_MIN);
assert(json_uit["uint_max"].uint64_value() == UINT_MAX);
assert(json_uit["uint_min"].uint64_value() == 0);

assert(json_uit["i64_max"].int64_value() == LLONG_MAX);
assert(json_uit["i64_min"].int64_value() == LLONG_MIN);
assert(json_uit["ui64_max"].uint64_value() == ULLONG_MAX);
assert(json_uit["ui64_min"].uint64_value() == 0);

So I forked and enhanced at https://github.com/taozhijiang/json11/ I know you will still not accept these pull request, so I will not create it. Despite javascript likely language, I think can managed in most cases. Thanks for your previous work, very nice!