forked from nfarina/feeds
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nfarina#11 from marramgrass/deprecate-jsonkit
Replace JSONKit with NSJSONSerialization.
- Loading branch information
Showing
10 changed files
with
148 additions
and
3,332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// NSData+ObjectFromJSONData.h | ||
// Feeds | ||
// | ||
// Created by Mark Goody on 16/04/2014. | ||
// Copyright (c) 2014 Spotlight Mobile. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSData (ObjectFromJSONData) | ||
|
||
- (id)objectFromJSONData; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// NSData+ObjectFromJSONData.m | ||
// Feeds | ||
// | ||
// Created by Mark Goody on 16/04/2014. | ||
// Copyright (c) 2014 Spotlight Mobile. All rights reserved. | ||
// | ||
|
||
#import "NSData+ObjectFromJSONData.h" | ||
|
||
@implementation NSData (ObjectFromJSONData) | ||
|
||
- (id)objectFromJSONData | ||
{ | ||
NSError *decodingError = nil; | ||
id object = [NSJSONSerialization JSONObjectWithData:self | ||
options:NSJSONReadingAllowFragments | ||
error:&decodingError]; | ||
|
||
if (object == nil && decodingError != nil) { | ||
NSLog(@"Error decoding JSON data"); | ||
} | ||
|
||
return object; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// NSDictionary+JSONString.h | ||
// Feeds | ||
// | ||
// Created by Mark Goody on 17/04/2014. | ||
// Copyright (c) 2014 Spotlight Mobile. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSDictionary (JSONString) | ||
|
||
- (NSString *)JSONString; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// NSDictionary+JSONString.m | ||
// Feeds | ||
// | ||
// Created by Mark Goody on 17/04/2014. | ||
// Copyright (c) 2014 Spotlight Mobile. All rights reserved. | ||
// | ||
|
||
#import "NSDictionary+JSONString.h" | ||
|
||
@implementation NSDictionary (JSONString) | ||
|
||
- (NSString *)JSONString | ||
{ | ||
NSError *encodingError = nil; | ||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:self | ||
options:0 | ||
error:&encodingError]; | ||
|
||
if (jsonData == nil && encodingError != nil) { | ||
NSLog(@"Error encoding JSON data for dictionary: %@", encodingError.localizedDescription); | ||
} | ||
|
||
NSString *jsonString = nil; | ||
if (jsonData != nil) { | ||
jsonString = [[NSString alloc] initWithBytes:jsonData.bytes | ||
length:jsonData.length | ||
encoding:NSUTF8StringEncoding]; | ||
} | ||
|
||
return jsonString; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// NSString+ObjectFromJSONString.h | ||
// Feeds | ||
// | ||
// Created by Mark Goody on 17/04/2014. | ||
// Copyright (c) 2014 Spotlight Mobile. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSString (ObjectFromJSONString) | ||
|
||
- (id)objectFromJSONString; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// NSString+ObjectFromJSONString.m | ||
// Feeds | ||
// | ||
// Created by Mark Goody on 17/04/2014. | ||
// Copyright (c) 2014 Spotlight Mobile. All rights reserved. | ||
// | ||
|
||
#import "NSString+ObjectFromJSONString.h" | ||
#import "NSData+ObjectFromJSONData.h" | ||
|
||
@implementation NSString (ObjectFromJSONString) | ||
|
||
- (id)objectFromJSONString | ||
{ | ||
NSData *jsonData = [self dataUsingEncoding:NSUTF8StringEncoding]; | ||
|
||
return [jsonData objectFromJSONData]; | ||
} | ||
|
||
@end |
Oops, something went wrong.