I have doublein NSNumber.
double myDouble = 1363395572.6129999;
NSNumber *doubleNumber = @(myDouble);
Here it becomes problematic.
doubleNumber.doubleValueseems to return the correct and complete value (1363395572.6129999)
However, looking at doubleNumberthe debugger or doing doubleNumber.description, they give me (1363395572.613).
I would understand, maybe it was just some display formatting, but when I insert this object into the JSON payload, the inserted rounded value is inserted instead of the actual number.
The way I do it looks something like this:
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:(Dictionary containing NSNumber)
options:0 error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
Looking at the line at this point, I see a truncated number with 3 decimal places, although the one NSNumberI inserted was 7.
My question is: why is this happening and more importantly, how can I stop it?
EDIT with the conclusion:
, , , , NSNumber double , . , , JSON.
, , ( , ) API,
, , JSON, JSON NSDecimalNumber, NSNumber. , , , , .