summaryrefslogtreecommitdiffstats
path: root/Classes/Source/Experimental/CJSONSerialization.m
diff options
context:
space:
mode:
authormatt handler <matt.handler@gmail.com>2011-04-25 02:21:36 -0400
committermatt handler <matt.handler@gmail.com>2011-04-25 02:21:36 -0400
commitab0c357216564967ccbb900923ead3830a13752b (patch)
tree1b3aa223efb245d47b9c6ba785d2db4e911fd62a /Classes/Source/Experimental/CJSONSerialization.m
parent0c7a7586d3c2ab22adb15f032b0a69c962aaeeaf (diff)
downloadpiccast-app-ab0c357216564967ccbb900923ead3830a13752b.tar.gz
piccast-app-ab0c357216564967ccbb900923ead3830a13752b.zip
added json stuff, sources are loading but not connected to any sensical database or nothing... coming together. next hard bit is going to be the animation when things update
Diffstat (limited to 'Classes/Source/Experimental/CJSONSerialization.m')
-rw-r--r--Classes/Source/Experimental/CJSONSerialization.m59
1 files changed, 59 insertions, 0 deletions
diff --git a/Classes/Source/Experimental/CJSONSerialization.m b/Classes/Source/Experimental/CJSONSerialization.m
new file mode 100644
index 0000000..5f603f6
--- /dev/null
+++ b/Classes/Source/Experimental/CJSONSerialization.m
@@ -0,0 +1,59 @@
+//
+// CJSONSerialization.m
+// TouchJSON
+//
+// Created by Jonathan Wight on 03/04/11.
+// Copyright 2011 toxicsoftware.com. All rights reserved.
+//
+
+#import "CJSONSerialization.h"
+
+#import "CJSONDeserializer.h"
+#import "CJSONSerializer.h"
+
+@implementation CJSONSerialization
+
++ (BOOL)isValidJSONObject:(id)obj
+ {
+ CJSONSerializer *theSerializer = [CJSONSerializer serializer];
+ return([theSerializer isValidJSONObject:obj]);
+ }
+
++ (NSData *)dataWithJSONObject:(id)obj options:(EJSONWritingOptions)opt error:(NSError **)error
+ {
+ #pragma unused (opt)
+
+ CJSONSerializer *theSerializer = [CJSONSerializer serializer];
+ NSData *theData = [theSerializer serializeObject:obj error:error];
+ return(theData);
+ }
+
++ (id)JSONObjectWithData:(NSData *)data options:(EJSONReadingOptions)opt error:(NSError **)error
+ {
+ CJSONDeserializer *theDeserializer = [CJSONDeserializer deserializer];
+ theDeserializer.options = (opt & kCJSONReadingMutableContainers ? 0 : kJSONDeserializationOptions_MutableContainers)
+ | (opt & kCJSONReadingMutableLeaves ? 0 : kJSONDeserializationOptions_MutableLeaves);
+ id theObject = [theDeserializer deserialize:data error:error];
+ return(theObject);
+ }
+
++ (NSInteger)writeJSONObject:(id)obj toStream:(NSOutputStream *)stream options:(EJSONWritingOptions)opt error:(NSError **)error
+ {
+ // TODO -- this is a quick work around.
+ NSInteger theSize = -1;
+ NSData *theData = [self dataWithJSONObject:obj options:opt error:error];
+ if (theData)
+ {
+ theSize = [stream write:[theData bytes] maxLength:[theData length]];
+ }
+ return(theSize);
+ }
+
++ (id)JSONObjectWithStream:(NSInputStream *)stream options:(EJSONReadingOptions)opt error:(NSError **)error
+ {
+ #pragma unused (stream, opt, error)
+ // TODO -- how much to read? Ugh.
+ return(NULL);
+ }
+
+@end