Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Commit

Permalink
moved this to the same file
Browse files Browse the repository at this point in the history
  • Loading branch information
zbowling committed Oct 22, 2011
1 parent ec9a8b0 commit 54f90d4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
15 changes: 2 additions & 13 deletions AFNetworking/AFHTTPClient.m
Expand Up @@ -24,6 +24,7 @@

#import "AFHTTPClient.h"
#import "AFHTTPRequestOperation.h"
#import "AFJSONRequestOperation.h"

#import <Availability.h>

Expand Down Expand Up @@ -118,19 +119,7 @@ - (id)initWithStringEncoding:(NSStringEncoding)encoding;
}

static NSString * AFJSONStringFromParameters(NSDictionary *parameters) {
NSString *JSONString = nil;

#if USE_FOUNDATION_JSON
NSError *error = nil;
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error];
if (!error) {
JSONString = [[[NSString alloc] initWithData:JSONData encoding:NSUTF8StringEncoding] autorelease];
}
#else
JSONString = [parameters JSONString];
#endif

return JSONString;
return [AFNETWORKING_DEFAULT_JSON_OPERATION JSONStringWithDictionary:parameters];
}

static NSString * AFPropertyListStringFromParameters(NSDictionary *parameters) {
Expand Down
2 changes: 2 additions & 0 deletions AFNetworking/AFJSONRequestOperation.h
Expand Up @@ -89,6 +89,8 @@
*/
+ (id)decodeJSONObjectWithData:(NSData *)data error:(NSError **)error;

+ (NSString *)JSONStringWithDictionary:(NSDictionary *)dictionary;

@end

#ifdef AF_INCLUDE_FOUNDATIONJSON
Expand Down
20 changes: 20 additions & 0 deletions AFNetworking/AFJSONRequestOperation.m
Expand Up @@ -103,6 +103,11 @@ + (id) decodeJSONObjectWithData:(NSData *)data error:(NSError **)error {
return nil;
}

+ (NSString *)JSONStringWithDictionary:(NSDictionary *)dictionary {
[self doesNotRecognizeSelector: _cmd];
return nil;
}

- (id)responseJSON {
return self.decodedResponse;
}
Expand Down Expand Up @@ -138,6 +143,16 @@ + (id) decodeJSONObjectWithData:(NSData *)data error:(NSError **)error {
}
}


+ (NSString *)JSONStringWithDictionary:(NSDictionary *)dictionary {
NSError *error = nil;
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:&error];
if (!error) {
return [[[NSString alloc] initWithData:JSONData encoding:NSUTF8StringEncoding] autorelease];
}
return nil;
}

@end
#endif

Expand All @@ -154,6 +169,11 @@ + (id) decodeJSONObjectWithData:(NSData *)data error:(NSError **)error {
}
}

+ (NSString *)JSONStringWithDictionary:(NSDictionary *)dictionary {
return [dictionary JSONString];
}


@end
#endif

0 comments on commit 54f90d4

Please sign in to comment.