forked from pkyeck/socket.IO-objc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSocketIOJSONSerialization.m
37 lines (32 loc) · 1 KB
/
SocketIOJSONSerialization.m
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
//
// SocketIOJSONSerialization.m
// v0.5 ARC
//
// based on
// socketio-cocoa https://github.com/fpotter/socketio-cocoa
// by Fred Potter <[email protected]>
//
// using
// https://github.com/square/SocketRocket
// https://github.com/stig/json-framework/
//
// reusing some parts of
// /socket.io/socket.io.js
//
// Created by Philipp Kyeck http://beta-interactive.de
//
// Updated by
// samlown https://github.com/samlown
// kayleg https://github.com/kayleg
// taiyangc https://github.com/taiyangc
//
#import "SocketIOJSONSerialization.h"
@implementation SocketIOJSONSerialization
+ (id) objectFromJSONData:(NSData *)data error:(NSError **)error {
return [NSJSONSerialization JSONObjectWithData:data options:0 error:error];
}
+ (NSString *) JSONStringFromObject:(id)object error:(NSError **)error {
NSData *data = [NSJSONSerialization dataWithJSONObject:object options:0 error:error];
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
@end