Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: johnezang/JSONKit
base: master
...
head fork: apptentive/PrefixedJSONKit
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 8 commits
  • 4 files changed
  • 1 commit comment
  • 1 contributor
Showing with 733 additions and 699 deletions.
  1. +0 −251 JSONKit.h
  2. +260 −0 PJSONKit.h
  3. +467 −448 JSONKit.m → PJSONKit.m
  4. +6 −0 README.md
View
251 JSONKit.h
@@ -1,251 +0,0 @@
-//
-// JSONKit.h
-// http://github.com/johnezang/JSONKit
-// Dual licensed under either the terms of the BSD License, or alternatively
-// under the terms of the Apache License, Version 2.0, as specified below.
-//
-
-/*
- Copyright (c) 2011, John Engelhart
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the Zang Industries nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/*
- Copyright 2011 John Engelhart
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-#include <stddef.h>
-#include <stdint.h>
-#include <limits.h>
-#include <TargetConditionals.h>
-#include <AvailabilityMacros.h>
-
-#ifdef __OBJC__
-#import <Foundation/NSArray.h>
-#import <Foundation/NSData.h>
-#import <Foundation/NSDictionary.h>
-#import <Foundation/NSError.h>
-#import <Foundation/NSObjCRuntime.h>
-#import <Foundation/NSString.h>
-#endif // __OBJC__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-// For Mac OS X < 10.5.
-#ifndef NSINTEGER_DEFINED
-#define NSINTEGER_DEFINED
-#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-#define NSIntegerMin LONG_MIN
-#define NSIntegerMax LONG_MAX
-#define NSUIntegerMax ULONG_MAX
-#else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
-typedef int NSInteger;
-typedef unsigned int NSUInteger;
-#define NSIntegerMin INT_MIN
-#define NSIntegerMax INT_MAX
-#define NSUIntegerMax UINT_MAX
-#endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
-#endif // NSINTEGER_DEFINED
-
-
-#ifndef _JSONKIT_H_
-#define _JSONKIT_H_
-
-#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
-#define JK_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
-#else
-#define JK_DEPRECATED_ATTRIBUTE
-#endif
-
-#define JSONKIT_VERSION_MAJOR 1
-#define JSONKIT_VERSION_MINOR 4
-
-typedef NSUInteger JKFlags;
-
-/*
- JKParseOptionComments : Allow C style // and /_* ... *_/ (without a _, obviously) comments in JSON.
- JKParseOptionUnicodeNewlines : Allow Unicode recommended (?:\r\n|[\n\v\f\r\x85\p{Zl}\p{Zp}]) newlines.
- JKParseOptionLooseUnicode : Normally the decoder will stop with an error at any malformed Unicode.
- This option allows JSON with malformed Unicode to be parsed without reporting an error.
- Any malformed Unicode is replaced with \uFFFD, or "REPLACEMENT CHARACTER".
- */
-
-enum {
- JKParseOptionNone = 0,
- JKParseOptionStrict = 0,
- JKParseOptionComments = (1 << 0),
- JKParseOptionUnicodeNewlines = (1 << 1),
- JKParseOptionLooseUnicode = (1 << 2),
- JKParseOptionPermitTextAfterValidJSON = (1 << 3),
- JKParseOptionValidFlags = (JKParseOptionComments | JKParseOptionUnicodeNewlines | JKParseOptionLooseUnicode | JKParseOptionPermitTextAfterValidJSON),
-};
-typedef JKFlags JKParseOptionFlags;
-
-enum {
- JKSerializeOptionNone = 0,
- JKSerializeOptionPretty = (1 << 0),
- JKSerializeOptionEscapeUnicode = (1 << 1),
- JKSerializeOptionEscapeForwardSlashes = (1 << 4),
- JKSerializeOptionValidFlags = (JKSerializeOptionPretty | JKSerializeOptionEscapeUnicode | JKSerializeOptionEscapeForwardSlashes),
-};
-typedef JKFlags JKSerializeOptionFlags;
-
-#ifdef __OBJC__
-
-typedef struct JKParseState JKParseState; // Opaque internal, private type.
-
-// As a general rule of thumb, if you use a method that doesn't accept a JKParseOptionFlags argument, it defaults to JKParseOptionStrict
-
-@interface JSONDecoder : NSObject {
- JKParseState *parseState;
-}
-+ (id)decoder;
-+ (id)decoderWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
-- (id)initWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
-- (void)clearCache;
-
-// The parse... methods were deprecated in v1.4 in favor of the v1.4 objectWith... methods.
-- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length: instead.
-- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length:error: instead.
-// The NSData MUST be UTF8 encoded JSON.
-- (id)parseJSONData:(NSData *)jsonData JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData: instead.
-- (id)parseJSONData:(NSData *)jsonData error:(NSError **)error JK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData:error: instead.
-
-// Methods that return immutable collection objects.
-- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
-- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
-// The NSData MUST be UTF8 encoded JSON.
-- (id)objectWithData:(NSData *)jsonData;
-- (id)objectWithData:(NSData *)jsonData error:(NSError **)error;
-
-// Methods that return mutable collection objects.
-- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
-- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
-// The NSData MUST be UTF8 encoded JSON.
-- (id)mutableObjectWithData:(NSData *)jsonData;
-- (id)mutableObjectWithData:(NSData *)jsonData error:(NSError **)error;
-
-@end
-
-////////////
-#pragma mark Deserializing methods
-////////////
-
-@interface NSString (JSONKitDeserializing)
-- (id)objectFromJSONString;
-- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
-- (id)objectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
-- (id)mutableObjectFromJSONString;
-- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
-- (id)mutableObjectFromJSONStringWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
-@end
-
-@interface NSData (JSONKitDeserializing)
-// The NSData MUST be UTF8 encoded JSON.
-- (id)objectFromJSONData;
-- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
-- (id)objectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
-- (id)mutableObjectFromJSONData;
-- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags;
-- (id)mutableObjectFromJSONDataWithParseOptions:(JKParseOptionFlags)parseOptionFlags error:(NSError **)error;
-@end
-
-////////////
-#pragma mark Serializing methods
-////////////
-
-@interface NSString (JSONKitSerializing)
-// Convenience methods for those that need to serialize the receiving NSString (i.e., instead of having to serialize a NSArray with a single NSString, you can "serialize to JSON" just the NSString).
-// Normally, a string that is serialized to JSON has quotation marks surrounding it, which you may or may not want when serializing a single string, and can be controlled with includeQuotes:
-// includeQuotes:YES `a "test"...` -> `"a \"test\"..."`
-// includeQuotes:NO `a "test"...` -> `a \"test\"...`
-- (NSData *)JSONData; // Invokes JSONDataWithOptions:JKSerializeOptionNone includeQuotes:YES
-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
-- (NSString *)JSONString; // Invokes JSONStringWithOptions:JKSerializeOptionNone includeQuotes:YES
-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
-@end
-
-@interface NSArray (JSONKitSerializing)
-- (NSData *)JSONData;
-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
-- (NSString *)JSONString;
-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
-@end
-
-@interface NSDictionary (JSONKitSerializing)
-- (NSData *)JSONData;
-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
-- (NSString *)JSONString;
-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions error:(NSError **)error;
-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
-@end
-
-#ifdef __BLOCKS__
-
-@interface NSArray (JSONKitSerializingBlockAdditions)
-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
-@end
-
-@interface NSDictionary (JSONKitSerializingBlockAdditions)
-- (NSData *)JSONDataWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
-- (NSString *)JSONStringWithOptions:(JKSerializeOptionFlags)serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
-@end
-
-#endif
-
-
-#endif // __OBJC__
-
-#endif // _JSONKIT_H_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
View
260 PJSONKit.h
@@ -0,0 +1,260 @@
+//
+// JSONKit.h
+// http://github.com/johnezang/JSONKit
+// Dual licensed under either the terms of the BSD License, or alternatively
+// under the terms of the Apache License, Version 2.0, as specified below.
+//
+
+/*
+ Copyright (c) 2011, John Engelhart
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ * Neither the name of the Zang Industries nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+ Copyright 2011 John Engelhart
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+#include <stddef.h>
+#include <stdint.h>
+#include <limits.h>
+#include <TargetConditionals.h>
+#include <AvailabilityMacros.h>
+
+#ifdef __OBJC__
+#import <Foundation/NSArray.h>
+#import <Foundation/NSData.h>
+#import <Foundation/NSDictionary.h>
+#import <Foundation/NSError.h>
+#import <Foundation/NSObjCRuntime.h>
+#import <Foundation/NSString.h>
+#endif // __OBJC__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// For Mac OS X < 10.5.
+#ifndef NSINTEGER_DEFINED
+#define NSINTEGER_DEFINED
+#if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+#define NSIntegerMin LONG_MIN
+#define NSIntegerMax LONG_MAX
+#define NSUIntegerMax ULONG_MAX
+#else // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+#define NSIntegerMin INT_MIN
+#define NSIntegerMax INT_MAX
+#define NSUIntegerMax UINT_MAX
+#endif // defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
+#endif // NSINTEGER_DEFINED
+
+
+#ifndef _PREFIXEDJSONKIT_H_
+#define _PREFIXEDJSONKIT_H_
+
+#ifdef JSONKIT_PREFIX
+#define _JSONKIT_CONCAT2(c, d) c ## d
+#define _JSONKIT_CONCAT(a, b) _JSONKIT_CONCAT2(a, b)
+#define JSONKIT_PREPEND(x) _JSONKIT_CONCAT(JSONKIT_PREFIX, x)
+#define _JSONKIT_STRINGIFY2(x) #x
+#define JSONKIT_STRINGIFY(x) _JSONKIT_STRINGIFY2(x)
+#else
+#define JSONKIT_PREPEND(x) x
+#endif
+
+#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
+#define PJK_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
+#else
+#define PJK_DEPRECATED_ATTRIBUTE
+#endif
+
+#define PREFIXEDJSONKIT_VERSION_MAJOR 1
+#define PREFIXEDJSONKIT_VERSION_MINOR 4
+
+typedef NSUInteger JSONKIT_PREPEND(JKFlags);
+
+/*
+ JKParseOptionComments : Allow C style // and /_* ... *_/ (without a _, obviously) comments in JSON.
+ JKParseOptionUnicodeNewlines : Allow Unicode recommended (?:\r\n|[\n\v\f\r\x85\p{Zl}\p{Zp}]) newlines.
+ JKParseOptionLooseUnicode : Normally the decoder will stop with an error at any malformed Unicode.
+ This option allows JSON with malformed Unicode to be parsed without reporting an error.
+ Any malformed Unicode is replaced with \uFFFD, or "REPLACEMENT CHARACTER".
+ */
+
+enum {
+ JSONKIT_PREPEND(JKParseOptionNone) = 0,
+ JSONKIT_PREPEND(JKParseOptionStrict) = 0,
+ JSONKIT_PREPEND(JKParseOptionComments) = (1 << 0),
+ JSONKIT_PREPEND(JKParseOptionUnicodeNewlines) = (1 << 1),
+ JSONKIT_PREPEND(JKParseOptionLooseUnicode) = (1 << 2),
+ JSONKIT_PREPEND(JKParseOptionPermitTextAfterValidJSON) = (1 << 3),
+ JSONKIT_PREPEND(JKParseOptionValidFlags) = (JSONKIT_PREPEND(JKParseOptionComments) | JSONKIT_PREPEND(JKParseOptionUnicodeNewlines) | JSONKIT_PREPEND(JKParseOptionLooseUnicode) | JSONKIT_PREPEND(JKParseOptionPermitTextAfterValidJSON)),
+};
+typedef JSONKIT_PREPEND(JKFlags) JSONKIT_PREPEND(JKParseOptionFlags);
+
+enum {
+ JSONKIT_PREPEND(JKSerializeOptionNone) = 0,
+ JSONKIT_PREPEND(JKSerializeOptionPretty) = (1 << 0),
+ JSONKIT_PREPEND(JKSerializeOptionEscapeUnicode) = (1 << 1),
+ JSONKIT_PREPEND(JKSerializeOptionEscapeForwardSlashes) = (1 << 4),
+ JSONKIT_PREPEND(JKSerializeOptionValidFlags) = (JSONKIT_PREPEND(JKSerializeOptionPretty) | JSONKIT_PREPEND(JKSerializeOptionEscapeUnicode) | JSONKIT_PREPEND(JKSerializeOptionEscapeForwardSlashes)),
+};
+typedef JSONKIT_PREPEND(JKFlags) JSONKIT_PREPEND(JKSerializeOptionFlags);
+
+#ifdef __OBJC__
+
+typedef struct JSONKIT_PREPEND(JKParseState) JSONKIT_PREPEND(JKParseState); // Opaque internal, private type.
+
+// As a general rule of thumb, if you use a method that doesn't accept a JKParseOptionFlags argument, it defaults to JKParseOptionStrict
+
+@interface JSONKIT_PREPEND(JSONDecoder) : NSObject {
+ JSONKIT_PREPEND(JKParseState) *parseState;
+}
++ (id)decoder;
++ (id)decoderWithParseOptions:(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags;
+- (id)initWithParseOptions:(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags;
+- (void)clearCache;
+
+// The parse... methods were deprecated in v1.4 in favor of the v1.4 objectWith... methods.
+- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length PJK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length: instead.
+- (id)parseUTF8String:(const unsigned char *)string length:(size_t)length error:(NSError **)error PJK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithUTF8String:length:error: instead.
+// The NSData MUST be UTF8 encoded JSON.
+- (id)parseJSONData:(NSData *)jsonData PJK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData: instead.
+- (id)parseJSONData:(NSData *)jsonData error:(NSError **)error PJK_DEPRECATED_ATTRIBUTE; // Deprecated in JSONKit v1.4. Use objectWithData:error: instead.
+
+// Methods that return immutable collection objects.
+- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
+- (id)objectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
+// The NSData MUST be UTF8 encoded JSON.
+- (id)objectWithData:(NSData *)jsonData;
+- (id)objectWithData:(NSData *)jsonData error:(NSError **)error;
+
+// Methods that return mutable collection objects.
+- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length;
+- (id)mutableObjectWithUTF8String:(const unsigned char *)string length:(NSUInteger)length error:(NSError **)error;
+// The NSData MUST be UTF8 encoded JSON.
+- (id)mutableObjectWithData:(NSData *)jsonData;
+- (id)mutableObjectWithData:(NSData *)jsonData error:(NSError **)error;
+
+@end
+
+////////////
+#pragma mark Deserializing methods
+////////////
+
+@interface NSString (JSONKIT_PREPEND(JSONKitDeserializing))
+- (id)JSONKIT_PREPEND(objectFromJSONString);
+- (id)JSONKIT_PREPEND(objectFromJSONStringWithParseOptions):(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags;
+- (id)JSONKIT_PREPEND(objectFromJSONStringWithParseOptions):(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags error:(NSError **)error;
+- (id)JSONKIT_PREPEND(mutableObjectFromJSONString);
+- (id)JSONKIT_PREPEND(mutableObjectFromJSONStringWithParseOptions):(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags;
+- (id)JSONKIT_PREPEND(mutableObjectFromJSONStringWithParseOptions):(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags error:(NSError **)error;
+@end
+
+@interface NSData (JSONKIT_PREPEND(JSONKitDeserializing))
+// The NSData MUST be UTF8 encoded JSON.
+- (id)JSONKIT_PREPEND(objectFromJSONData);
+- (id)JSONKIT_PREPEND(objectFromJSONDataWithParseOptions):(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags;
+- (id)JSONKIT_PREPEND(objectFromJSONDataWithParseOptions):(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags error:(NSError **)error;
+- (id)JSONKIT_PREPEND(mutableObjectFromJSONData);
+- (id)JSONKIT_PREPEND(mutableObjectFromJSONDataWithParseOptions):(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags;
+- (id)JSONKIT_PREPEND(mutableObjectFromJSONDataWithParseOptions):(JSONKIT_PREPEND(JKParseOptionFlags))parseOptionFlags error:(NSError **)error;
+@end
+
+////////////
+#pragma mark Serializing methods
+////////////
+
+@interface NSString (JSONKIT_PREPEND(JSONKitSerializing))
+// Convenience methods for those that need to serialize the receiving NSString (i.e., instead of having to serialize a NSArray with a single NSString, you can "serialize to JSON" just the NSString).
+// Normally, a string that is serialized to JSON has quotation marks surrounding it, which you may or may not want when serializing a single string, and can be controlled with includeQuotes:
+// includeQuotes:YES `a "test"...` -> `"a \"test\"..."`
+// includeQuotes:NO `a "test"...` -> `a \"test\"...`
+- (NSData *)JSONKIT_PREPEND(JSONData); // Invokes JSONDataWithOptions:JKSerializeOptionNone includeQuotes:YES
+- (NSData *)JSONKIT_PREPEND(JSONDataWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
+- (NSString *)JSONKIT_PREPEND(JSONString); // Invokes JSONStringWithOptions:JKSerializeOptionNone includeQuotes:YES
+- (NSString *)JSONKIT_PREPEND(JSONStringWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions includeQuotes:(BOOL)includeQuotes error:(NSError **)error;
+@end
+
+@interface NSArray (JSONKIT_PREPEND(JSONKitSerializing))
+- (NSData *)JSONKIT_PREPEND(JSONData);
+- (NSData *)JSONKIT_PREPEND(JSONDataWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions error:(NSError **)error;
+- (NSData *)JSONKIT_PREPEND(JSONDataWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
+- (NSString *)JSONKIT_PREPEND(JSONString);
+- (NSString *)JSONKIT_PREPEND(JSONStringWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions error:(NSError **)error;
+- (NSString *)JSONKIT_PREPEND(JSONStringWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
+@end
+
+@interface NSDictionary (JSONKIT_PREPEND(JSONKitSerializing))
+- (NSData *)JSONKIT_PREPEND(JSONData);
+- (NSData *)JSONKIT_PREPEND(JSONDataWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions error:(NSError **)error;
+- (NSData *)JSONKIT_PREPEND(JSONDataWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
+- (NSString *)JSONKIT_PREPEND(JSONString);
+- (NSString *)JSONKIT_PREPEND(JSONStringWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions error:(NSError **)error;
+- (NSString *)JSONKIT_PREPEND(JSONStringWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions serializeUnsupportedClassesUsingDelegate:(id)delegate selector:(SEL)selector error:(NSError **)error;
+@end
+
+#ifdef __BLOCKS__
+
+@interface NSArray (JSONKIT_PREPEND(JSONKitSerializingBlockAdditions))
+- (NSData *)JSONKIT_PREPEND(JSONDataWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
+- (NSString *)JSONKIT_PREPEND(JSONStringWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
+@end
+
+@interface NSDictionary (JSONKIT_PREPEND(JSONKitSerializingBlockAdditions))
+- (NSData *)JSONKIT_PREPEND(JSONDataWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
+- (NSString *)JSONKIT_PREPEND(JSONStringWithOptions):(JSONKIT_PREPEND(JKSerializeOptionFlags))serializeOptions serializeUnsupportedClassesUsingBlock:(id(^)(id object))block error:(NSError **)error;
+@end
+
+#endif
+
+
+#endif // __OBJC__
+
+#endif // _PREFIXEDJSONKIT_H_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
View
915 JSONKit.m → PJSONKit.m
467 additions, 448 deletions not shown
View
6 README.md
@@ -1,3 +1,9 @@
+# PrefixedJSONKit
+
+PrefixedJSONKit is a fork of JSONKit which prefixes the symbols in JSONKit for easy embedding in static libraries to avoid conflicts with other uses of JSONKit in the same binary.
+
+To use, set a preprocessor macro for `JSONKIT_PREFIX`, for example: `JSONKIT_PREFIX=EXAMPLE_`. Now, all external JSONKit symbols will be prefixed with "EXAMPLE_", so `JSONDecoder` would become `EXAMPLE_JSONDecoder`.
+
# JSONKit
JSONKit is dual licensed under either the terms of the BSD License, or alternatively under the terms of the Apache License, Version 2.0.<br />

Showing you all comments on commits in this comparison.

@SpencerP

Awesome, that fixed it! Thank you!

Something went wrong with that request. Please try again.