blob: b0cb10a2f6646ee669485360d7e057955ba15d84 (
plain)
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
|
/* NSJSONSerialization+HBAdditions.m $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */
#import "NSJSONSerialization+HBAdditions.h"
@implementation NSJSONSerialization (HBAdditions)
+ (id)HB_JSONObjectWithUTF8String:(const char *)nullTerminatedCString options:(NSJSONReadingOptions)opt error:(NSError * __autoreleasing *)error
{
if (!nullTerminatedCString) {
return nil;
}
NSData *data = [NSData dataWithBytes:nullTerminatedCString length:strlen(nullTerminatedCString)];
id result = [NSJSONSerialization JSONObjectWithData:data options:opt error:error];
return result;
}
+ (NSString *)HB_StringWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError * __autoreleasing *)error
{
NSData *data = [NSJSONSerialization dataWithJSONObject:obj options:opt error:error];
if (data)
{
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
return nil;
}
@end
|