-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSimpleHttpClientFilterForJSON.m
More file actions
39 lines (32 loc) · 1.03 KB
/
SimpleHttpClientFilterForJSON.m
File metadata and controls
39 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#import "SimpleHttpClientFilterForJSON.h"
#import "NSDictionary+BSJSONAdditions.h"
#import "NSArray+BSJSONAdditions.h"
@implementation SimpleHttpClientFilterForJSON
//----------------------------------------------------------------------------//
#pragma mark -- APIs --
//----------------------------------------------------------------------------//
- (id)apply:(NSData *)data
{
NSString *jsonString = [NSString stringWithUTF8String:[data bytes]];
for (NSInteger i = 0; i < [jsonString length]; i++) {
unichar nextChar = [jsonString characterAtIndex:i];
switch (nextChar) {
case '\n':
break;
case '\r':
break;
case '\t':
break;
case ' ':
break;
case '{':
return [NSDictionary dictionaryWithJSONString:jsonString];
case '[':
return [NSArray arrayWithJSONString:jsonString];
default:
break;
}
}
return nil;
}
@end