mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-28 12:45:33 +08:00
Refactor JSONRepresentation to stringFromObject: on RKParser. Fixes https://github.com/twotoasters/RestKit/issues/#issue/6
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
//
|
||||
|
||||
#import "RKJSONSerialization.h"
|
||||
#import "NSObject+SBJSON.h"
|
||||
#import "NSObject+RKJSONSerialization.h"
|
||||
#import "RKJSONParser.h"
|
||||
|
||||
@implementation RKJSONSerialization
|
||||
|
||||
@@ -33,7 +34,7 @@
|
||||
}
|
||||
|
||||
- (NSString*)JSONRepresentation {
|
||||
return [_object JSONRepresentation];
|
||||
return [[[[RKJSONParser alloc] init] autorelease] stringFromObject:_object];
|
||||
}
|
||||
|
||||
- (NSData*)HTTPBody {
|
||||
@@ -43,10 +44,9 @@
|
||||
- (BOOL)isEqual:(id)object {
|
||||
if ([object isKindOfClass:[NSString class]]) {
|
||||
return [[self JSONRepresentation] isEqualToString:object];
|
||||
} if ([object respondsToSelector:@selector(JSONRepresentation)]) {
|
||||
return [[self JSONRepresentation] isEqualToString:[(NSObject*)object JSONRepresentation]];
|
||||
} else {
|
||||
return NO;
|
||||
NSString* string = [[[[RKJSONParser alloc] init] autorelease] stringFromObject:object];
|
||||
return [[self JSONRepresentation] isEqualToString:string];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import "RKJSONParser.h"
|
||||
#import "SBJsonParser.h"
|
||||
#import "NSObject+SBJSON.h"
|
||||
|
||||
@implementation RKJSONParser
|
||||
|
||||
@@ -23,4 +24,8 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSString*)stringFromObject:(id)object {
|
||||
return [object JSONRepresentation];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -15,4 +15,8 @@
|
||||
return [string yajl_JSON];
|
||||
}
|
||||
|
||||
- (NSString*)stringFromObject:(id)object {
|
||||
return [object yajl_JSONString];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -20,4 +20,6 @@
|
||||
*/
|
||||
- (id)objectFromString:(NSString*)string;
|
||||
|
||||
- (NSString*)stringFromObject:(id)object;
|
||||
|
||||
@end
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
3F3CE40F125B9B450083FDCB /* BG@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F3CE40B125B9B450083FDCB /* BG@2x.png */; };
|
||||
3F3CE410125B9B450083FDCB /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F3CE40C125B9B450083FDCB /* Default.png */; };
|
||||
3F3CE411125B9B450083FDCB /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F3CE40D125B9B450083FDCB /* Default@2x.png */; };
|
||||
84F524B512824D2C00C370EA /* libRestKitJSONParserYAJL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F3CE2CB125B93780083FDCB /* libRestKitJSONParserYAJL.a */; };
|
||||
3FECA57512D2413B0023437F /* libRestKitJSONParserSBJSON.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F3CE2CD125B93780083FDCB /* libRestKitJSONParserSBJSON.a */; };
|
||||
84F524B612824D2D00C370EA /* libRestKitNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F3CE2C5125B93780083FDCB /* libRestKitNetwork.a */; };
|
||||
84F524B712824D2E00C370EA /* libRestKitObjectMapping.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F3CE2C7125B93780083FDCB /* libRestKitObjectMapping.a */; };
|
||||
84F524B812824D2F00C370EA /* libRestKitSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3F3CE2C9125B93780083FDCB /* libRestKitSupport.a */; };
|
||||
@@ -137,13 +137,13 @@
|
||||
288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */,
|
||||
2538E865123424F000ACB5D7 /* CoreData.framework in Frameworks */,
|
||||
2538E8671234250100ACB5D7 /* SystemConfiguration.framework in Frameworks */,
|
||||
84F524B512824D2C00C370EA /* libRestKitJSONParserYAJL.a in Frameworks */,
|
||||
84F524B612824D2D00C370EA /* libRestKitNetwork.a in Frameworks */,
|
||||
84F524B712824D2E00C370EA /* libRestKitObjectMapping.a in Frameworks */,
|
||||
84F524B812824D2F00C370EA /* libRestKitSupport.a in Frameworks */,
|
||||
84F524C212824D5000C370EA /* CFNetwork.framework in Frameworks */,
|
||||
84F524C612824D5B00C370EA /* MobileCoreServices.framework in Frameworks */,
|
||||
84F524D012824D8800C370EA /* libRestKitCoreData.a in Frameworks */,
|
||||
3FECA57512D2413B0023437F /* libRestKitJSONParserSBJSON.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -392,6 +392,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
BUILD_STYLE = Debug;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
@@ -411,6 +412,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
BUILD_STYLE = Release;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = RKTwitter_Prefix.pch;
|
||||
@@ -429,6 +431,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
BUILD_STYLE = Debug;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
@@ -442,6 +445,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
BUILD_STYLE = Release;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
|
||||
@@ -2164,7 +2164,7 @@
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = UISpec;
|
||||
SDKROOT = iphoneos4.1;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "";
|
||||
};
|
||||
@@ -2202,7 +2202,7 @@
|
||||
);
|
||||
PREBINDING = NO;
|
||||
PRODUCT_NAME = UISpec;
|
||||
SDKROOT = iphoneos4.1;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
ZERO_LINK = NO;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user