Take the following piece of code:
NSError *error;
NSString *myJSONString = @\"{ \\\"foo\\\" : 0.1}\";
NSData *jsonData = [myJSONString dataUsingEncoding:NSUTF8St
NSJSONSerialization
(and JSONSerialization
in Swift) follow the general pattern:
long long
. If that doesn't overflow, return an NSNumber
with long long
.strtod_l
. If it doesn't overflow, return an NSNumber
with double
.NSDecimalNumber
which supports a much larger range of values, specifically a mantissa up to 38 digits and exponent between -128...127.If you look at other examples people have posted you can see that when the value exceeds the range or precision of a double
you get an NSDecimalNumber
back.