From: Aaron J. <ja...@go...> - 2011-05-23 21:34:42
|
On Mon, May 23, 2011 at 9:50 PM, Baptiste Lepilleur <bap...@gm...> wrote: > If I understood your problem correctly, this should solve your backward > compatibility issue. Is that correct? Almost but not quite, I think. Now the numbers in [2^32, 2^64) will be parsed as uint64s, and the code above will always return kError because both isUInt and isDouble return false, even though it used to work for those values. I think maybe the only choice here is to have each of the isFoo methods return true iff asFoo will work, whether that's the best way to represent the number or not. For example: 0.7 -> isDouble 1 -> isUInt, isInt, isUInt64, isInt64, isDouble 2^32 -> isUInt, isUInt64, isDouble 2^40 -> isUInt64, isDouble 2^64 - 1 -> isDouble 2^64 -> isDouble I can imagine that this change would cause problems for other existing code, but I'm not sure. What do you think? Perhaps the best way would have been to have users explicitly opt in for 64-bit support. That is, add an option to the constructor of Json::Reader that defaults to false, and if you set it to true then you're asserting that your code doesn't suffer from the problem mentioned above. I guess it's too late for that, though. |