From ae4347ee403b8b8ba8f156fd856496770ae07ab0 Mon Sep 17 00:00:00 2001 From: rfm Date: Thu, 19 Sep 2013 14:17:56 +0000 Subject: [PATCH] cope with output of large integers git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37117 72102866-910b-0410-8b05-ffd578937521 --- Source/NSJSONSerialization.m | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/NSJSONSerialization.m b/Source/NSJSONSerialization.m index 26ada245f..17a9ebacc 100644 --- a/Source/NSJSONSerialization.m +++ b/Source/NSJSONSerialization.m @@ -891,7 +891,18 @@ writeObject(id obj, NSMutableString *output, NSInteger tabs) } else if ([obj isKindOfClass: NSNumberClass]) { - [output appendFormat: @"%g", [obj doubleValue]]; + const char *t = [obj objCType]; + + if (strchr("cCsSiIlLqQ", *t) != 0) + { + long long i = [(NSNumber*)obj longLongValue]; + + [output appendFormat: @"%lld", i]; + } + else + { + [output appendFormat: @"%g", [(NSNumber*)obj doubleValue]]; + } } else if ([obj isKindOfClass: NSNullClass]) {