├── .gitignore ├── .gitmodules ├── CoreJSON.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── CoreJSON ├── CoreJSON-Info.plist ├── CoreJSON-Prefix.pch ├── CoreJSON.c ├── CoreJSON.h └── en.lproj │ └── InfoPlist.strings ├── CoreJSONTests ├── CoreJSONTests-Info.plist ├── CoreJSONTests-Prefix.pch ├── CoreJSONTests.h ├── CoreJSONTests.m ├── en.lproj │ └── InfoPlist.strings └── tests │ └── sample.json ├── Readme.md ├── YAJL.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata └── YAJL ├── YAJL-Info.plist ├── YAJL-Prefix.pch ├── en.lproj └── InfoPlist.strings └── include └── yajl ├── yajl_common.h ├── yajl_gen.h ├── yajl_parse.h ├── yajl_tree.h └── yajl_version.h /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build 3 | *.xcodeproj/project.xcworkspace/xcuserdata 4 | *.xcodeproj/xcuserdata 5 | *.xcodeproj/*.mode1v3 6 | *.xcodeproj/*.pbxuser 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "YAJL/yajl"] 2 | path = YAJL/yajl 3 | url = git://github.com/lloyd/yajl.git 4 | [submodule "CoreJSONTests/CoreTestAllocator"] 5 | path = CoreJSONTests/CoreTestAllocator 6 | url = git://github.com/mirek/CoreTestAllocator.git 7 | -------------------------------------------------------------------------------- /CoreJSON.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | EB173E221316C2AE00C173A9 /* yajl_alloc.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E141316C2AE00C173A9 /* yajl_alloc.c */; }; 11 | EB173E231316C2AE00C173A9 /* yajl_alloc.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E141316C2AE00C173A9 /* yajl_alloc.c */; }; 12 | EB173E241316C2AE00C173A9 /* yajl_alloc.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E141316C2AE00C173A9 /* yajl_alloc.c */; }; 13 | EB173E251316C2AE00C173A9 /* yajl_alloc.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E151316C2AE00C173A9 /* yajl_alloc.h */; }; 14 | EB173E261316C2AE00C173A9 /* yajl_alloc.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E151316C2AE00C173A9 /* yajl_alloc.h */; }; 15 | EB173E271316C2AE00C173A9 /* yajl_buf.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E161316C2AE00C173A9 /* yajl_buf.c */; }; 16 | EB173E281316C2AE00C173A9 /* yajl_buf.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E161316C2AE00C173A9 /* yajl_buf.c */; }; 17 | EB173E291316C2AE00C173A9 /* yajl_buf.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E161316C2AE00C173A9 /* yajl_buf.c */; }; 18 | EB173E2A1316C2AE00C173A9 /* yajl_buf.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E171316C2AE00C173A9 /* yajl_buf.h */; }; 19 | EB173E2B1316C2AE00C173A9 /* yajl_buf.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E171316C2AE00C173A9 /* yajl_buf.h */; }; 20 | EB173E2C1316C2AE00C173A9 /* yajl_bytestack.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E181316C2AE00C173A9 /* yajl_bytestack.h */; }; 21 | EB173E2D1316C2AE00C173A9 /* yajl_bytestack.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E181316C2AE00C173A9 /* yajl_bytestack.h */; }; 22 | EB173E2E1316C2AE00C173A9 /* yajl_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E191316C2AE00C173A9 /* yajl_encode.c */; }; 23 | EB173E2F1316C2AE00C173A9 /* yajl_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E191316C2AE00C173A9 /* yajl_encode.c */; }; 24 | EB173E301316C2AE00C173A9 /* yajl_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E191316C2AE00C173A9 /* yajl_encode.c */; }; 25 | EB173E311316C2AE00C173A9 /* yajl_encode.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E1A1316C2AE00C173A9 /* yajl_encode.h */; }; 26 | EB173E321316C2AE00C173A9 /* yajl_encode.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E1A1316C2AE00C173A9 /* yajl_encode.h */; }; 27 | EB173E331316C2AE00C173A9 /* yajl_gen.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E1B1316C2AE00C173A9 /* yajl_gen.c */; }; 28 | EB173E341316C2AE00C173A9 /* yajl_gen.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E1B1316C2AE00C173A9 /* yajl_gen.c */; }; 29 | EB173E351316C2AE00C173A9 /* yajl_gen.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E1B1316C2AE00C173A9 /* yajl_gen.c */; }; 30 | EB173E361316C2AE00C173A9 /* yajl_lex.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E1C1316C2AE00C173A9 /* yajl_lex.c */; }; 31 | EB173E371316C2AE00C173A9 /* yajl_lex.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E1C1316C2AE00C173A9 /* yajl_lex.c */; }; 32 | EB173E381316C2AE00C173A9 /* yajl_lex.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E1C1316C2AE00C173A9 /* yajl_lex.c */; }; 33 | EB173E391316C2AE00C173A9 /* yajl_lex.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E1D1316C2AE00C173A9 /* yajl_lex.h */; }; 34 | EB173E3A1316C2AE00C173A9 /* yajl_lex.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E1D1316C2AE00C173A9 /* yajl_lex.h */; }; 35 | EB173E3B1316C2AE00C173A9 /* yajl_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E1E1316C2AE00C173A9 /* yajl_parser.c */; }; 36 | EB173E3C1316C2AE00C173A9 /* yajl_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E1E1316C2AE00C173A9 /* yajl_parser.c */; }; 37 | EB173E3D1316C2AE00C173A9 /* yajl_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E1E1316C2AE00C173A9 /* yajl_parser.c */; }; 38 | EB173E3E1316C2AE00C173A9 /* yajl_parser.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E1F1316C2AE00C173A9 /* yajl_parser.h */; }; 39 | EB173E3F1316C2AE00C173A9 /* yajl_parser.h in Headers */ = {isa = PBXBuildFile; fileRef = EB173E1F1316C2AE00C173A9 /* yajl_parser.h */; }; 40 | EB173E401316C2AE00C173A9 /* yajl_version.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E201316C2AE00C173A9 /* yajl_version.c */; }; 41 | EB173E411316C2AE00C173A9 /* yajl_version.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E201316C2AE00C173A9 /* yajl_version.c */; }; 42 | EB173E421316C2AE00C173A9 /* yajl_version.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E201316C2AE00C173A9 /* yajl_version.c */; }; 43 | EB173E431316C2AE00C173A9 /* yajl.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E211316C2AE00C173A9 /* yajl.c */; }; 44 | EB173E441316C2AE00C173A9 /* yajl.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E211316C2AE00C173A9 /* yajl.c */; }; 45 | EB173E451316C2AE00C173A9 /* yajl.c in Sources */ = {isa = PBXBuildFile; fileRef = EB173E211316C2AE00C173A9 /* yajl.c */; }; 46 | EB59CC2D1376F99B00C02960 /* yajl_tree.c in Sources */ = {isa = PBXBuildFile; fileRef = EB59CC2C1376F99B00C02960 /* yajl_tree.c */; }; 47 | EB59CC2E1376F99B00C02960 /* yajl_tree.c in Sources */ = {isa = PBXBuildFile; fileRef = EB59CC2C1376F99B00C02960 /* yajl_tree.c */; }; 48 | EB59CC2F1376F99B00C02960 /* yajl_tree.c in Sources */ = {isa = PBXBuildFile; fileRef = EB59CC2C1376F99B00C02960 /* yajl_tree.c */; }; 49 | EBA2F87E1379AA5C002E5AD4 /* CoreTestAllocator.c in Sources */ = {isa = PBXBuildFile; fileRef = EBA2F87C1379AA5C002E5AD4 /* CoreTestAllocator.c */; }; 50 | EBB1ADE01312A9DE006476A7 /* CoreJSON.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB81076130BEC8C00CF5EF8 /* CoreJSON.c */; }; 51 | EBB1ADE21312A9ED006476A7 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBB1ADE11312A9ED006476A7 /* CoreFoundation.framework */; }; 52 | EBB1ADE41312AA16006476A7 /* CoreJSON.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB81077130BEC8C00CF5EF8 /* CoreJSON.h */; settings = {ATTRIBUTES = (Public, ); }; }; 53 | EBB1AE7F1312B683006476A7 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBB1AE7E1312B683006476A7 /* Cocoa.framework */; }; 54 | EBB81057130BEC3E00CF5EF8 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = EBB81055130BEC3E00CF5EF8 /* InfoPlist.strings */; }; 55 | EBB81062130BEC3E00CF5EF8 /* CoreJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBB81049130BEC3E00CF5EF8 /* CoreJSON.framework */; }; 56 | EBB81068130BEC3E00CF5EF8 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = EBB81066130BEC3E00CF5EF8 /* InfoPlist.strings */; }; 57 | EBB8106B130BEC3E00CF5EF8 /* CoreJSONTests.h in Resources */ = {isa = PBXBuildFile; fileRef = EBB8106A130BEC3E00CF5EF8 /* CoreJSONTests.h */; }; 58 | EBB8106D130BEC3E00CF5EF8 /* CoreJSONTests.m in Sources */ = {isa = PBXBuildFile; fileRef = EBB8106C130BEC3E00CF5EF8 /* CoreJSONTests.m */; }; 59 | EBB81078130BEC8C00CF5EF8 /* CoreJSON.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB81076130BEC8C00CF5EF8 /* CoreJSON.c */; }; 60 | EBB81079130BEC8C00CF5EF8 /* CoreJSON.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB81077130BEC8C00CF5EF8 /* CoreJSON.h */; }; 61 | EBCA2947131F03C400361057 /* sample.json in Resources */ = {isa = PBXBuildFile; fileRef = EBCA2946131F03C400361057 /* sample.json */; }; 62 | EBCB75E6130C0F36009F0B55 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBCB75E5130C0F36009F0B55 /* CoreFoundation.framework */; }; 63 | EBCB75E9130C1074009F0B55 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBCB75E5130C0F36009F0B55 /* CoreFoundation.framework */; }; 64 | /* End PBXBuildFile section */ 65 | 66 | /* Begin PBXContainerItemProxy section */ 67 | EBB81060130BEC3E00CF5EF8 /* PBXContainerItemProxy */ = { 68 | isa = PBXContainerItemProxy; 69 | containerPortal = EBB8103F130BEC3E00CF5EF8 /* Project object */; 70 | proxyType = 1; 71 | remoteGlobalIDString = EBB81048130BEC3E00CF5EF8; 72 | remoteInfo = CoreJSON; 73 | }; 74 | /* End PBXContainerItemProxy section */ 75 | 76 | /* Begin PBXFileReference section */ 77 | EB173E141316C2AE00C173A9 /* yajl_alloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_alloc.c; path = YAJL/yajl/src/yajl_alloc.c; sourceTree = SOURCE_ROOT; }; 78 | EB173E151316C2AE00C173A9 /* yajl_alloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_alloc.h; path = YAJL/yajl/src/yajl_alloc.h; sourceTree = SOURCE_ROOT; }; 79 | EB173E161316C2AE00C173A9 /* yajl_buf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_buf.c; path = YAJL/yajl/src/yajl_buf.c; sourceTree = SOURCE_ROOT; }; 80 | EB173E171316C2AE00C173A9 /* yajl_buf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_buf.h; path = YAJL/yajl/src/yajl_buf.h; sourceTree = SOURCE_ROOT; }; 81 | EB173E181316C2AE00C173A9 /* yajl_bytestack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_bytestack.h; path = YAJL/yajl/src/yajl_bytestack.h; sourceTree = SOURCE_ROOT; }; 82 | EB173E191316C2AE00C173A9 /* yajl_encode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_encode.c; path = YAJL/yajl/src/yajl_encode.c; sourceTree = SOURCE_ROOT; }; 83 | EB173E1A1316C2AE00C173A9 /* yajl_encode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_encode.h; path = YAJL/yajl/src/yajl_encode.h; sourceTree = SOURCE_ROOT; }; 84 | EB173E1B1316C2AE00C173A9 /* yajl_gen.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_gen.c; path = YAJL/yajl/src/yajl_gen.c; sourceTree = SOURCE_ROOT; }; 85 | EB173E1C1316C2AE00C173A9 /* yajl_lex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_lex.c; path = YAJL/yajl/src/yajl_lex.c; sourceTree = SOURCE_ROOT; }; 86 | EB173E1D1316C2AE00C173A9 /* yajl_lex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_lex.h; path = YAJL/yajl/src/yajl_lex.h; sourceTree = SOURCE_ROOT; }; 87 | EB173E1E1316C2AE00C173A9 /* yajl_parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_parser.c; path = YAJL/yajl/src/yajl_parser.c; sourceTree = SOURCE_ROOT; }; 88 | EB173E1F1316C2AE00C173A9 /* yajl_parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_parser.h; path = YAJL/yajl/src/yajl_parser.h; sourceTree = SOURCE_ROOT; }; 89 | EB173E201316C2AE00C173A9 /* yajl_version.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_version.c; path = YAJL/yajl/src/yajl_version.c; sourceTree = SOURCE_ROOT; }; 90 | EB173E211316C2AE00C173A9 /* yajl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl.c; path = YAJL/yajl/src/yajl.c; sourceTree = SOURCE_ROOT; }; 91 | EB59CC2C1376F99B00C02960 /* yajl_tree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_tree.c; path = YAJL/yajl/src/yajl_tree.c; sourceTree = SOURCE_ROOT; }; 92 | EB7354C2130E688300D6C2D8 /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = Readme.md; sourceTree = ""; }; 93 | EBA2F87C1379AA5C002E5AD4 /* CoreTestAllocator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = CoreTestAllocator.c; path = CoreTestAllocator/CoreTestAllocator.c; sourceTree = ""; }; 94 | EBA2F87D1379AA5C002E5AD4 /* CoreTestAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CoreTestAllocator.h; path = CoreTestAllocator/CoreTestAllocator.h; sourceTree = ""; }; 95 | EBB1ADD81312A7B6006476A7 /* libCoreJSON (iOS).a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = "libCoreJSON (iOS).a"; path = libCoreJSON_iOS.a; sourceTree = BUILT_PRODUCTS_DIR; }; 96 | EBB1ADE11312A9ED006476A7 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/Frameworks/CoreFoundation.framework; sourceTree = DEVELOPER_DIR; }; 97 | EBB1AE7E1312B683006476A7 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 98 | EBB81049130BEC3E00CF5EF8 /* CoreJSON.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CoreJSON.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 99 | EBB81054130BEC3E00CF5EF8 /* CoreJSON-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CoreJSON-Info.plist"; sourceTree = ""; }; 100 | EBB81056130BEC3E00CF5EF8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 101 | EBB81058130BEC3E00CF5EF8 /* CoreJSON-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CoreJSON-Prefix.pch"; sourceTree = ""; }; 102 | EBB8105E130BEC3E00CF5EF8 /* CoreJSONTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreJSONTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 103 | EBB81065130BEC3E00CF5EF8 /* CoreJSONTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CoreJSONTests-Info.plist"; sourceTree = ""; }; 104 | EBB81067130BEC3E00CF5EF8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 105 | EBB81069130BEC3E00CF5EF8 /* CoreJSONTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CoreJSONTests-Prefix.pch"; sourceTree = ""; }; 106 | EBB8106A130BEC3E00CF5EF8 /* CoreJSONTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreJSONTests.h; sourceTree = ""; }; 107 | EBB8106C130BEC3E00CF5EF8 /* CoreJSONTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CoreJSONTests.m; sourceTree = ""; }; 108 | EBB81076130BEC8C00CF5EF8 /* CoreJSON.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CoreJSON.c; sourceTree = ""; }; 109 | EBB81077130BEC8C00CF5EF8 /* CoreJSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreJSON.h; sourceTree = ""; }; 110 | EBCA2946131F03C400361057 /* sample.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = sample.json; sourceTree = ""; }; 111 | EBCB75E5130C0F36009F0B55 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; 112 | /* End PBXFileReference section */ 113 | 114 | /* Begin PBXFrameworksBuildPhase section */ 115 | EBB1ADD51312A7B6006476A7 /* Frameworks */ = { 116 | isa = PBXFrameworksBuildPhase; 117 | buildActionMask = 2147483647; 118 | files = ( 119 | EBB1ADE21312A9ED006476A7 /* CoreFoundation.framework in Frameworks */, 120 | ); 121 | runOnlyForDeploymentPostprocessing = 0; 122 | }; 123 | EBB81045130BEC3E00CF5EF8 /* Frameworks */ = { 124 | isa = PBXFrameworksBuildPhase; 125 | buildActionMask = 2147483647; 126 | files = ( 127 | EBCB75E6130C0F36009F0B55 /* CoreFoundation.framework in Frameworks */, 128 | ); 129 | runOnlyForDeploymentPostprocessing = 0; 130 | }; 131 | EBB8105A130BEC3E00CF5EF8 /* Frameworks */ = { 132 | isa = PBXFrameworksBuildPhase; 133 | buildActionMask = 2147483647; 134 | files = ( 135 | EBB1AE7F1312B683006476A7 /* Cocoa.framework in Frameworks */, 136 | EBB81062130BEC3E00CF5EF8 /* CoreJSON.framework in Frameworks */, 137 | EBCB75E9130C1074009F0B55 /* CoreFoundation.framework in Frameworks */, 138 | ); 139 | runOnlyForDeploymentPostprocessing = 0; 140 | }; 141 | /* End PBXFrameworksBuildPhase section */ 142 | 143 | /* Begin PBXGroup section */ 144 | EB173E131316C28800C173A9 /* YAJL */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | EB173E141316C2AE00C173A9 /* yajl_alloc.c */, 148 | EB173E151316C2AE00C173A9 /* yajl_alloc.h */, 149 | EB173E161316C2AE00C173A9 /* yajl_buf.c */, 150 | EB173E171316C2AE00C173A9 /* yajl_buf.h */, 151 | EB173E181316C2AE00C173A9 /* yajl_bytestack.h */, 152 | EB173E191316C2AE00C173A9 /* yajl_encode.c */, 153 | EB173E1A1316C2AE00C173A9 /* yajl_encode.h */, 154 | EB173E1B1316C2AE00C173A9 /* yajl_gen.c */, 155 | EB173E1C1316C2AE00C173A9 /* yajl_lex.c */, 156 | EB173E1D1316C2AE00C173A9 /* yajl_lex.h */, 157 | EB173E1E1316C2AE00C173A9 /* yajl_parser.c */, 158 | EB173E1F1316C2AE00C173A9 /* yajl_parser.h */, 159 | EB59CC2C1376F99B00C02960 /* yajl_tree.c */, 160 | EB173E201316C2AE00C173A9 /* yajl_version.c */, 161 | EB173E211316C2AE00C173A9 /* yajl.c */, 162 | ); 163 | name = YAJL; 164 | sourceTree = ""; 165 | }; 166 | EBB1ADE31312A9F5006476A7 /* iOS */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | EBB1ADE11312A9ED006476A7 /* CoreFoundation.framework */, 170 | ); 171 | name = iOS; 172 | sourceTree = ""; 173 | }; 174 | EBB1AE311312B22A006476A7 /* OSX */ = { 175 | isa = PBXGroup; 176 | children = ( 177 | EBB1AE7E1312B683006476A7 /* Cocoa.framework */, 178 | EBCB75E5130C0F36009F0B55 /* CoreFoundation.framework */, 179 | ); 180 | name = OSX; 181 | sourceTree = ""; 182 | }; 183 | EBB8103D130BEC3E00CF5EF8 = { 184 | isa = PBXGroup; 185 | children = ( 186 | EBB81052130BEC3E00CF5EF8 /* CoreJSON */, 187 | EBB81063130BEC3E00CF5EF8 /* CoreJSONTests */, 188 | EBB8104B130BEC3E00CF5EF8 /* Frameworks */, 189 | EBB8104A130BEC3E00CF5EF8 /* Products */, 190 | EB7354C2130E688300D6C2D8 /* Readme.md */, 191 | ); 192 | sourceTree = ""; 193 | }; 194 | EBB8104A130BEC3E00CF5EF8 /* Products */ = { 195 | isa = PBXGroup; 196 | children = ( 197 | EBB81049130BEC3E00CF5EF8 /* CoreJSON.framework */, 198 | EBB8105E130BEC3E00CF5EF8 /* CoreJSONTests.octest */, 199 | EBB1ADD81312A7B6006476A7 /* libCoreJSON (iOS).a */, 200 | ); 201 | name = Products; 202 | sourceTree = ""; 203 | }; 204 | EBB8104B130BEC3E00CF5EF8 /* Frameworks */ = { 205 | isa = PBXGroup; 206 | children = ( 207 | EBB1ADE31312A9F5006476A7 /* iOS */, 208 | EBB1AE311312B22A006476A7 /* OSX */, 209 | ); 210 | name = Frameworks; 211 | sourceTree = ""; 212 | }; 213 | EBB81052130BEC3E00CF5EF8 /* CoreJSON */ = { 214 | isa = PBXGroup; 215 | children = ( 216 | EB173E131316C28800C173A9 /* YAJL */, 217 | EBB81053130BEC3E00CF5EF8 /* Supporting Files */, 218 | EBB81077130BEC8C00CF5EF8 /* CoreJSON.h */, 219 | EBB81076130BEC8C00CF5EF8 /* CoreJSON.c */, 220 | ); 221 | path = CoreJSON; 222 | sourceTree = ""; 223 | }; 224 | EBB81053130BEC3E00CF5EF8 /* Supporting Files */ = { 225 | isa = PBXGroup; 226 | children = ( 227 | EBB81054130BEC3E00CF5EF8 /* CoreJSON-Info.plist */, 228 | EBB81055130BEC3E00CF5EF8 /* InfoPlist.strings */, 229 | EBB81058130BEC3E00CF5EF8 /* CoreJSON-Prefix.pch */, 230 | ); 231 | name = "Supporting Files"; 232 | sourceTree = ""; 233 | }; 234 | EBB81063130BEC3E00CF5EF8 /* CoreJSONTests */ = { 235 | isa = PBXGroup; 236 | children = ( 237 | EBCA2945131F03C400361057 /* tests */, 238 | EBB8106A130BEC3E00CF5EF8 /* CoreJSONTests.h */, 239 | EBB8106C130BEC3E00CF5EF8 /* CoreJSONTests.m */, 240 | EBB81064130BEC3E00CF5EF8 /* Supporting Files */, 241 | ); 242 | path = CoreJSONTests; 243 | sourceTree = ""; 244 | }; 245 | EBB81064130BEC3E00CF5EF8 /* Supporting Files */ = { 246 | isa = PBXGroup; 247 | children = ( 248 | EBA2F87D1379AA5C002E5AD4 /* CoreTestAllocator.h */, 249 | EBA2F87C1379AA5C002E5AD4 /* CoreTestAllocator.c */, 250 | EBB81065130BEC3E00CF5EF8 /* CoreJSONTests-Info.plist */, 251 | EBB81066130BEC3E00CF5EF8 /* InfoPlist.strings */, 252 | EBB81069130BEC3E00CF5EF8 /* CoreJSONTests-Prefix.pch */, 253 | ); 254 | name = "Supporting Files"; 255 | sourceTree = ""; 256 | }; 257 | EBCA2945131F03C400361057 /* tests */ = { 258 | isa = PBXGroup; 259 | children = ( 260 | EBCA2946131F03C400361057 /* sample.json */, 261 | ); 262 | path = tests; 263 | sourceTree = ""; 264 | }; 265 | /* End PBXGroup section */ 266 | 267 | /* Begin PBXHeadersBuildPhase section */ 268 | EBB1ADD61312A7B6006476A7 /* Headers */ = { 269 | isa = PBXHeadersBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | EBB1ADE41312AA16006476A7 /* CoreJSON.h in Headers */, 273 | EB173E261316C2AE00C173A9 /* yajl_alloc.h in Headers */, 274 | EB173E2B1316C2AE00C173A9 /* yajl_buf.h in Headers */, 275 | EB173E2D1316C2AE00C173A9 /* yajl_bytestack.h in Headers */, 276 | EB173E321316C2AE00C173A9 /* yajl_encode.h in Headers */, 277 | EB173E3A1316C2AE00C173A9 /* yajl_lex.h in Headers */, 278 | EB173E3F1316C2AE00C173A9 /* yajl_parser.h in Headers */, 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | }; 282 | EBB81046130BEC3E00CF5EF8 /* Headers */ = { 283 | isa = PBXHeadersBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | EBB81079130BEC8C00CF5EF8 /* CoreJSON.h in Headers */, 287 | EB173E251316C2AE00C173A9 /* yajl_alloc.h in Headers */, 288 | EB173E2A1316C2AE00C173A9 /* yajl_buf.h in Headers */, 289 | EB173E2C1316C2AE00C173A9 /* yajl_bytestack.h in Headers */, 290 | EB173E311316C2AE00C173A9 /* yajl_encode.h in Headers */, 291 | EB173E391316C2AE00C173A9 /* yajl_lex.h in Headers */, 292 | EB173E3E1316C2AE00C173A9 /* yajl_parser.h in Headers */, 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | /* End PBXHeadersBuildPhase section */ 297 | 298 | /* Begin PBXNativeTarget section */ 299 | EBB1ADD71312A7B6006476A7 /* CoreJSON_iOS */ = { 300 | isa = PBXNativeTarget; 301 | buildConfigurationList = EBB1ADDD1312A7B6006476A7 /* Build configuration list for PBXNativeTarget "CoreJSON_iOS" */; 302 | buildPhases = ( 303 | EBB1ADD41312A7B6006476A7 /* Sources */, 304 | EBB1ADD51312A7B6006476A7 /* Frameworks */, 305 | EBB1ADD61312A7B6006476A7 /* Headers */, 306 | ); 307 | buildRules = ( 308 | ); 309 | dependencies = ( 310 | ); 311 | name = CoreJSON_iOS; 312 | productName = CoreJSON; 313 | productReference = EBB1ADD81312A7B6006476A7 /* libCoreJSON (iOS).a */; 314 | productType = "com.apple.product-type.library.static"; 315 | }; 316 | EBB81048130BEC3E00CF5EF8 /* CoreJSON */ = { 317 | isa = PBXNativeTarget; 318 | buildConfigurationList = EBB81070130BEC3E00CF5EF8 /* Build configuration list for PBXNativeTarget "CoreJSON" */; 319 | buildPhases = ( 320 | EBB81044130BEC3E00CF5EF8 /* Sources */, 321 | EBB81045130BEC3E00CF5EF8 /* Frameworks */, 322 | EBB81046130BEC3E00CF5EF8 /* Headers */, 323 | EBB81047130BEC3E00CF5EF8 /* Resources */, 324 | ); 325 | buildRules = ( 326 | ); 327 | dependencies = ( 328 | ); 329 | name = CoreJSON; 330 | productName = CoreJSON; 331 | productReference = EBB81049130BEC3E00CF5EF8 /* CoreJSON.framework */; 332 | productType = "com.apple.product-type.framework"; 333 | }; 334 | EBB8105D130BEC3E00CF5EF8 /* CoreJSONTests */ = { 335 | isa = PBXNativeTarget; 336 | buildConfigurationList = EBB81073130BEC3E00CF5EF8 /* Build configuration list for PBXNativeTarget "CoreJSONTests" */; 337 | buildPhases = ( 338 | EBB81059130BEC3E00CF5EF8 /* Sources */, 339 | EBB8105A130BEC3E00CF5EF8 /* Frameworks */, 340 | EBB8105B130BEC3E00CF5EF8 /* Resources */, 341 | EBB8105C130BEC3E00CF5EF8 /* ShellScript */, 342 | ); 343 | buildRules = ( 344 | ); 345 | dependencies = ( 346 | EBB81061130BEC3E00CF5EF8 /* PBXTargetDependency */, 347 | ); 348 | name = CoreJSONTests; 349 | productName = CoreJSONTests; 350 | productReference = EBB8105E130BEC3E00CF5EF8 /* CoreJSONTests.octest */; 351 | productType = "com.apple.product-type.bundle"; 352 | }; 353 | /* End PBXNativeTarget section */ 354 | 355 | /* Begin PBXProject section */ 356 | EBB8103F130BEC3E00CF5EF8 /* Project object */ = { 357 | isa = PBXProject; 358 | attributes = { 359 | ORGANIZATIONNAME = "Inteliv Ltd"; 360 | }; 361 | buildConfigurationList = EBB81042130BEC3E00CF5EF8 /* Build configuration list for PBXProject "CoreJSON" */; 362 | compatibilityVersion = "Xcode 3.2"; 363 | developmentRegion = English; 364 | hasScannedForEncodings = 0; 365 | knownRegions = ( 366 | en, 367 | ); 368 | mainGroup = EBB8103D130BEC3E00CF5EF8; 369 | productRefGroup = EBB8104A130BEC3E00CF5EF8 /* Products */; 370 | projectDirPath = ""; 371 | projectRoot = ""; 372 | targets = ( 373 | EBB81048130BEC3E00CF5EF8 /* CoreJSON */, 374 | EBB8105D130BEC3E00CF5EF8 /* CoreJSONTests */, 375 | EBB1ADD71312A7B6006476A7 /* CoreJSON_iOS */, 376 | ); 377 | }; 378 | /* End PBXProject section */ 379 | 380 | /* Begin PBXResourcesBuildPhase section */ 381 | EBB81047130BEC3E00CF5EF8 /* Resources */ = { 382 | isa = PBXResourcesBuildPhase; 383 | buildActionMask = 2147483647; 384 | files = ( 385 | EBB81057130BEC3E00CF5EF8 /* InfoPlist.strings in Resources */, 386 | ); 387 | runOnlyForDeploymentPostprocessing = 0; 388 | }; 389 | EBB8105B130BEC3E00CF5EF8 /* Resources */ = { 390 | isa = PBXResourcesBuildPhase; 391 | buildActionMask = 2147483647; 392 | files = ( 393 | EBB81068130BEC3E00CF5EF8 /* InfoPlist.strings in Resources */, 394 | EBB8106B130BEC3E00CF5EF8 /* CoreJSONTests.h in Resources */, 395 | EBCA2947131F03C400361057 /* sample.json in Resources */, 396 | ); 397 | runOnlyForDeploymentPostprocessing = 0; 398 | }; 399 | /* End PBXResourcesBuildPhase section */ 400 | 401 | /* Begin PBXShellScriptBuildPhase section */ 402 | EBB8105C130BEC3E00CF5EF8 /* ShellScript */ = { 403 | isa = PBXShellScriptBuildPhase; 404 | buildActionMask = 2147483647; 405 | files = ( 406 | ); 407 | inputPaths = ( 408 | ); 409 | outputPaths = ( 410 | ); 411 | runOnlyForDeploymentPostprocessing = 0; 412 | shellPath = /bin/sh; 413 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; 414 | }; 415 | /* End PBXShellScriptBuildPhase section */ 416 | 417 | /* Begin PBXSourcesBuildPhase section */ 418 | EBB1ADD41312A7B6006476A7 /* Sources */ = { 419 | isa = PBXSourcesBuildPhase; 420 | buildActionMask = 2147483647; 421 | files = ( 422 | EBB1ADE01312A9DE006476A7 /* CoreJSON.c in Sources */, 423 | EB173E241316C2AE00C173A9 /* yajl_alloc.c in Sources */, 424 | EB173E291316C2AE00C173A9 /* yajl_buf.c in Sources */, 425 | EB173E301316C2AE00C173A9 /* yajl_encode.c in Sources */, 426 | EB173E351316C2AE00C173A9 /* yajl_gen.c in Sources */, 427 | EB173E381316C2AE00C173A9 /* yajl_lex.c in Sources */, 428 | EB173E3D1316C2AE00C173A9 /* yajl_parser.c in Sources */, 429 | EB173E421316C2AE00C173A9 /* yajl_version.c in Sources */, 430 | EB173E451316C2AE00C173A9 /* yajl.c in Sources */, 431 | EB59CC2F1376F99B00C02960 /* yajl_tree.c in Sources */, 432 | ); 433 | runOnlyForDeploymentPostprocessing = 0; 434 | }; 435 | EBB81044130BEC3E00CF5EF8 /* Sources */ = { 436 | isa = PBXSourcesBuildPhase; 437 | buildActionMask = 2147483647; 438 | files = ( 439 | EBB81078130BEC8C00CF5EF8 /* CoreJSON.c in Sources */, 440 | EB173E221316C2AE00C173A9 /* yajl_alloc.c in Sources */, 441 | EB173E271316C2AE00C173A9 /* yajl_buf.c in Sources */, 442 | EB173E2E1316C2AE00C173A9 /* yajl_encode.c in Sources */, 443 | EB173E331316C2AE00C173A9 /* yajl_gen.c in Sources */, 444 | EB173E361316C2AE00C173A9 /* yajl_lex.c in Sources */, 445 | EB173E3B1316C2AE00C173A9 /* yajl_parser.c in Sources */, 446 | EB173E401316C2AE00C173A9 /* yajl_version.c in Sources */, 447 | EB173E431316C2AE00C173A9 /* yajl.c in Sources */, 448 | EB59CC2D1376F99B00C02960 /* yajl_tree.c in Sources */, 449 | ); 450 | runOnlyForDeploymentPostprocessing = 0; 451 | }; 452 | EBB81059130BEC3E00CF5EF8 /* Sources */ = { 453 | isa = PBXSourcesBuildPhase; 454 | buildActionMask = 2147483647; 455 | files = ( 456 | EBB8106D130BEC3E00CF5EF8 /* CoreJSONTests.m in Sources */, 457 | EB173E231316C2AE00C173A9 /* yajl_alloc.c in Sources */, 458 | EB173E281316C2AE00C173A9 /* yajl_buf.c in Sources */, 459 | EB173E2F1316C2AE00C173A9 /* yajl_encode.c in Sources */, 460 | EB173E341316C2AE00C173A9 /* yajl_gen.c in Sources */, 461 | EB173E371316C2AE00C173A9 /* yajl_lex.c in Sources */, 462 | EB173E3C1316C2AE00C173A9 /* yajl_parser.c in Sources */, 463 | EB173E411316C2AE00C173A9 /* yajl_version.c in Sources */, 464 | EB173E441316C2AE00C173A9 /* yajl.c in Sources */, 465 | EB59CC2E1376F99B00C02960 /* yajl_tree.c in Sources */, 466 | EBA2F87E1379AA5C002E5AD4 /* CoreTestAllocator.c in Sources */, 467 | ); 468 | runOnlyForDeploymentPostprocessing = 0; 469 | }; 470 | /* End PBXSourcesBuildPhase section */ 471 | 472 | /* Begin PBXTargetDependency section */ 473 | EBB81061130BEC3E00CF5EF8 /* PBXTargetDependency */ = { 474 | isa = PBXTargetDependency; 475 | target = EBB81048130BEC3E00CF5EF8 /* CoreJSON */; 476 | targetProxy = EBB81060130BEC3E00CF5EF8 /* PBXContainerItemProxy */; 477 | }; 478 | /* End PBXTargetDependency section */ 479 | 480 | /* Begin PBXVariantGroup section */ 481 | EBB81055130BEC3E00CF5EF8 /* InfoPlist.strings */ = { 482 | isa = PBXVariantGroup; 483 | children = ( 484 | EBB81056130BEC3E00CF5EF8 /* en */, 485 | ); 486 | name = InfoPlist.strings; 487 | sourceTree = ""; 488 | }; 489 | EBB81066130BEC3E00CF5EF8 /* InfoPlist.strings */ = { 490 | isa = PBXVariantGroup; 491 | children = ( 492 | EBB81067130BEC3E00CF5EF8 /* en */, 493 | ); 494 | name = InfoPlist.strings; 495 | sourceTree = ""; 496 | }; 497 | /* End PBXVariantGroup section */ 498 | 499 | /* Begin XCBuildConfiguration section */ 500 | EBB1ADDE1312A7B6006476A7 /* Debug */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | ALWAYS_SEARCH_USER_PATHS = NO; 504 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 505 | DSTROOT = /tmp/CoreJSON.dst; 506 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 507 | GCC_PREFIX_HEADER = "CoreJSON/CoreJSON-Prefix.pch"; 508 | GCC_VERSION = com.apple.compilers.llvmgcc42; 509 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 510 | INSTALL_PATH = ""; 511 | IPHONEOS_DEPLOYMENT_TARGET = 4.2; 512 | LIBRARY_SEARCH_PATHS = ( 513 | "$(inherited)", 514 | "\"$(SRCROOT)\"", 515 | ); 516 | MACOSX_DEPLOYMENT_TARGET = ""; 517 | OTHER_LDFLAGS = "-ObjC"; 518 | PRIVATE_HEADERS_FOLDER_PATH = ""; 519 | PRODUCT_NAME = "$(TARGET_NAME)"; 520 | PUBLIC_HEADERS_FOLDER_PATH = ""; 521 | SDKROOT = iphoneos; 522 | }; 523 | name = Debug; 524 | }; 525 | EBB1ADDF1312A7B6006476A7 /* Release */ = { 526 | isa = XCBuildConfiguration; 527 | buildSettings = { 528 | ALWAYS_SEARCH_USER_PATHS = NO; 529 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 530 | DSTROOT = /tmp/CoreJSON.dst; 531 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 532 | GCC_PREFIX_HEADER = "CoreJSON/CoreJSON-Prefix.pch"; 533 | GCC_VERSION = com.apple.compilers.llvmgcc42; 534 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 535 | INSTALL_PATH = ""; 536 | IPHONEOS_DEPLOYMENT_TARGET = 4.2; 537 | LIBRARY_SEARCH_PATHS = ( 538 | "$(inherited)", 539 | "\"$(SRCROOT)\"", 540 | ); 541 | MACOSX_DEPLOYMENT_TARGET = ""; 542 | OTHER_LDFLAGS = "-ObjC"; 543 | PRIVATE_HEADERS_FOLDER_PATH = ""; 544 | PRODUCT_NAME = "$(TARGET_NAME)"; 545 | PUBLIC_HEADERS_FOLDER_PATH = ""; 546 | SDKROOT = iphoneos; 547 | }; 548 | name = Release; 549 | }; 550 | EBB8106E130BEC3E00CF5EF8 /* Debug */ = { 551 | isa = XCBuildConfiguration; 552 | buildSettings = { 553 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 554 | GCC_C_LANGUAGE_STANDARD = gnu99; 555 | GCC_OPTIMIZATION_LEVEL = 0; 556 | GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 557 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 558 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 559 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 560 | GCC_WARN_UNUSED_VARIABLE = YES; 561 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 562 | MACOSX_DEPLOYMENT_TARGET = 10.6; 563 | ONLY_ACTIVE_ARCH = YES; 564 | SDKROOT = macosx; 565 | }; 566 | name = Debug; 567 | }; 568 | EBB8106F130BEC3E00CF5EF8 /* Release */ = { 569 | isa = XCBuildConfiguration; 570 | buildSettings = { 571 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 572 | GCC_C_LANGUAGE_STANDARD = gnu99; 573 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 574 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 575 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 576 | GCC_WARN_UNUSED_VARIABLE = YES; 577 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 578 | MACOSX_DEPLOYMENT_TARGET = 10.6; 579 | SDKROOT = macosx; 580 | }; 581 | name = Release; 582 | }; 583 | EBB81071130BEC3E00CF5EF8 /* Debug */ = { 584 | isa = XCBuildConfiguration; 585 | buildSettings = { 586 | ALWAYS_SEARCH_USER_PATHS = NO; 587 | COPY_PHASE_STRIP = NO; 588 | DYLIB_COMPATIBILITY_VERSION = 1; 589 | DYLIB_CURRENT_VERSION = 1; 590 | FRAMEWORK_SEARCH_PATHS = ( 591 | "$(inherited)", 592 | "\"$(SRCROOT)\"", 593 | ); 594 | FRAMEWORK_VERSION = A; 595 | GCC_DYNAMIC_NO_PIC = NO; 596 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 597 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 598 | GCC_PREFIX_HEADER = "CoreJSON/CoreJSON-Prefix.pch"; 599 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 600 | INFOPLIST_FILE = "CoreJSON/CoreJSON-Info.plist"; 601 | LIBRARY_SEARCH_PATHS = ""; 602 | PRODUCT_NAME = "$(TARGET_NAME)"; 603 | WRAPPER_EXTENSION = framework; 604 | }; 605 | name = Debug; 606 | }; 607 | EBB81072130BEC3E00CF5EF8 /* Release */ = { 608 | isa = XCBuildConfiguration; 609 | buildSettings = { 610 | ALWAYS_SEARCH_USER_PATHS = NO; 611 | COPY_PHASE_STRIP = YES; 612 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 613 | DYLIB_COMPATIBILITY_VERSION = 1; 614 | DYLIB_CURRENT_VERSION = 1; 615 | FRAMEWORK_SEARCH_PATHS = ( 616 | "$(inherited)", 617 | "\"$(SRCROOT)\"", 618 | ); 619 | FRAMEWORK_VERSION = A; 620 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 621 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 622 | GCC_PREFIX_HEADER = "CoreJSON/CoreJSON-Prefix.pch"; 623 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 624 | INFOPLIST_FILE = "CoreJSON/CoreJSON-Info.plist"; 625 | LIBRARY_SEARCH_PATHS = ""; 626 | PRODUCT_NAME = "$(TARGET_NAME)"; 627 | WRAPPER_EXTENSION = framework; 628 | }; 629 | name = Release; 630 | }; 631 | EBB81074130BEC3E00CF5EF8 /* Debug */ = { 632 | isa = XCBuildConfiguration; 633 | buildSettings = { 634 | ALWAYS_SEARCH_USER_PATHS = NO; 635 | COPY_PHASE_STRIP = NO; 636 | FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; 637 | GCC_DYNAMIC_NO_PIC = NO; 638 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 639 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 640 | GCC_PREFIX_HEADER = "CoreJSONTests/CoreJSONTests-Prefix.pch"; 641 | INFOPLIST_FILE = "CoreJSONTests/CoreJSONTests-Info.plist"; 642 | INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; 643 | OTHER_LDFLAGS = ( 644 | "-framework", 645 | SenTestingKit, 646 | ); 647 | PRODUCT_NAME = "$(TARGET_NAME)"; 648 | WRAPPER_EXTENSION = octest; 649 | }; 650 | name = Debug; 651 | }; 652 | EBB81075130BEC3E00CF5EF8 /* Release */ = { 653 | isa = XCBuildConfiguration; 654 | buildSettings = { 655 | ALWAYS_SEARCH_USER_PATHS = NO; 656 | COPY_PHASE_STRIP = YES; 657 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 658 | FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; 659 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 660 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 661 | GCC_PREFIX_HEADER = "CoreJSONTests/CoreJSONTests-Prefix.pch"; 662 | INFOPLIST_FILE = "CoreJSONTests/CoreJSONTests-Info.plist"; 663 | INSTALL_PATH = "$(USER_LIBRARY_DIR)/Bundles"; 664 | OTHER_LDFLAGS = ( 665 | "-framework", 666 | SenTestingKit, 667 | ); 668 | PRODUCT_NAME = "$(TARGET_NAME)"; 669 | WRAPPER_EXTENSION = octest; 670 | }; 671 | name = Release; 672 | }; 673 | /* End XCBuildConfiguration section */ 674 | 675 | /* Begin XCConfigurationList section */ 676 | EBB1ADDD1312A7B6006476A7 /* Build configuration list for PBXNativeTarget "CoreJSON_iOS" */ = { 677 | isa = XCConfigurationList; 678 | buildConfigurations = ( 679 | EBB1ADDE1312A7B6006476A7 /* Debug */, 680 | EBB1ADDF1312A7B6006476A7 /* Release */, 681 | ); 682 | defaultConfigurationIsVisible = 0; 683 | defaultConfigurationName = Release; 684 | }; 685 | EBB81042130BEC3E00CF5EF8 /* Build configuration list for PBXProject "CoreJSON" */ = { 686 | isa = XCConfigurationList; 687 | buildConfigurations = ( 688 | EBB8106E130BEC3E00CF5EF8 /* Debug */, 689 | EBB8106F130BEC3E00CF5EF8 /* Release */, 690 | ); 691 | defaultConfigurationIsVisible = 0; 692 | defaultConfigurationName = Release; 693 | }; 694 | EBB81070130BEC3E00CF5EF8 /* Build configuration list for PBXNativeTarget "CoreJSON" */ = { 695 | isa = XCConfigurationList; 696 | buildConfigurations = ( 697 | EBB81071130BEC3E00CF5EF8 /* Debug */, 698 | EBB81072130BEC3E00CF5EF8 /* Release */, 699 | ); 700 | defaultConfigurationIsVisible = 0; 701 | defaultConfigurationName = Release; 702 | }; 703 | EBB81073130BEC3E00CF5EF8 /* Build configuration list for PBXNativeTarget "CoreJSONTests" */ = { 704 | isa = XCConfigurationList; 705 | buildConfigurations = ( 706 | EBB81074130BEC3E00CF5EF8 /* Debug */, 707 | EBB81075130BEC3E00CF5EF8 /* Release */, 708 | ); 709 | defaultConfigurationIsVisible = 0; 710 | defaultConfigurationName = Release; 711 | }; 712 | /* End XCConfigurationList section */ 713 | }; 714 | rootObject = EBB8103F130BEC3E00CF5EF8 /* Project object */; 715 | } 716 | -------------------------------------------------------------------------------- /CoreJSON.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CoreJSON/CoreJSON-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.github.mirek.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | NSHumanReadableCopyright 26 | Copyright © 2011 Inteliv Ltd. All rights reserved. 27 | NSPrincipalClass 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /CoreJSON/CoreJSON-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'CoreJSON' target in the 'CoreJSON' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CoreJSON/CoreJSON.c: -------------------------------------------------------------------------------- 1 | // 2 | // CoreJSON.c 3 | // CoreJSON Framework 4 | // 5 | // Copyright 2011 Mirek Rusin 6 | // http://github.com/mirek/CoreJSON 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #include "CoreJSON.h" 22 | 23 | // Internal helper macro for appending elements 24 | #define __JSON_CONSUME_AND_RETURN(create) \ 25 | CFTypeRef __json_element = (create); \ 26 | int __json_return = __JSONStackAppendValueAtTop(json->stack, __JSONElementsAppend(json, __json_element)); \ 27 | CFRelease(__json_element); \ 28 | return __json_return 29 | 30 | #pragma Internal stack 31 | 32 | inline __JSONStackEntryRef __JSONStackEntryCreate(CFAllocatorRef allocator, CFIndex index, CFIndex valuesInitialSize, CFIndex keysInitialSize) { 33 | __JSONStackEntryRef entry = CFAllocatorAllocate(allocator, sizeof(__JSONStackEntry), 0); 34 | if (entry) { 35 | entry->allocator = allocator ? CFRetain(allocator) : NULL; 36 | entry->retainCount = 1; 37 | entry->index = index; 38 | entry->valuesIndex = 0; 39 | if ((entry->valuesSize = valuesInitialSize)) 40 | entry->values = CFAllocatorAllocate(entry->allocator, sizeof(CFIndex) * entry->valuesSize, 0); 41 | else 42 | entry->values = NULL; 43 | entry->keysIndex = 0; 44 | if ((entry->keysSize = keysInitialSize)) 45 | entry->keys = CFAllocatorAllocate(entry->allocator, sizeof(CFIndex) * entry->keysSize, 0); 46 | else 47 | entry->keys = NULL; 48 | } 49 | return entry; 50 | } 51 | 52 | inline __JSONStackEntryRef __JSONStackEntryRetain(__JSONStackEntryRef entry) { 53 | entry->retainCount++; 54 | return entry; 55 | } 56 | 57 | inline CFIndex __JSONStackEntryRelease(__JSONStackEntryRef entry) { 58 | CFIndex retainCount = 0; 59 | if (entry) { 60 | if ((retainCount = --entry->retainCount) == 0) { 61 | CFAllocatorRef allocator = entry->allocator; 62 | if (entry->values) 63 | CFAllocatorDeallocate(allocator, entry->values); 64 | if (entry->keys) 65 | CFAllocatorDeallocate(allocator, entry->keys); 66 | CFAllocatorDeallocate(allocator, entry); 67 | if (allocator) 68 | CFRelease(allocator); 69 | } 70 | } 71 | return retainCount; 72 | } 73 | 74 | inline bool __JSONStackEntryAppendValue(__JSONStackEntryRef entry, CFIndex value) { 75 | bool success = 0; 76 | if (entry) { 77 | if (entry->valuesIndex == entry->valuesSize) { // Reallocate more space 78 | CFIndex largerSize = entry->valuesSize ? entry->valuesSize << 1 : CORE_JSON_STACK_ENTRY_VALUES_INITIAL_SIZE; 79 | CFIndex *largerValues = CFAllocatorReallocate(entry->allocator, entry->values, sizeof(CFIndex) * largerSize, 0); 80 | if (largerValues) { 81 | entry->valuesSize = largerSize; 82 | entry->values = largerValues; 83 | } 84 | } 85 | if (entry->valuesIndex < entry->valuesSize) { 86 | entry->values[entry->valuesIndex++] = value; 87 | success = 1; 88 | } 89 | } 90 | return success; 91 | } 92 | 93 | inline bool __JSONStackEntryAppendKey(__JSONStackEntryRef entry, CFIndex key) { 94 | bool success = 0; 95 | if (entry) { 96 | if (entry->keysIndex == entry->keysSize) { // Reallocate more space 97 | CFIndex largerSize = entry->keysSize ? entry->keysSize << 1 : CORE_JSON_STACK_ENTRY_KEYS_INITIAL_SIZE; 98 | CFIndex *largerKeys = CFAllocatorReallocate(entry->allocator, entry->keys, sizeof(CFIndex) * largerSize, 0); 99 | if (largerKeys) { 100 | entry->keysSize = largerSize; 101 | entry->keys = largerKeys; 102 | } 103 | } 104 | if (entry->keysIndex < entry->keysSize) { 105 | entry->keys[entry->keysIndex++] = key; 106 | success = 1; 107 | } 108 | } 109 | return success; 110 | } 111 | 112 | inline CFTypeRef *__JSONStackEntryCreateValues(__JSONStackEntryRef entry, CFTypeRef *elements) { 113 | CFTypeRef *values = CFAllocatorAllocate(entry->allocator, sizeof(CFTypeRef) * entry->valuesIndex, 0); 114 | if (values) 115 | for (CFIndex i = 0; i < entry->valuesIndex; i++) 116 | values[i] = elements[entry->values[i]]; 117 | return values; 118 | } 119 | 120 | inline CFTypeRef *__JSONStackEntryCreateKeys(__JSONStackEntryRef entry, CFTypeRef *elements) { 121 | CFTypeRef *keys = CFAllocatorAllocate(entry->allocator, sizeof(CFTypeRef) * entry->keysIndex, 0); 122 | if (keys) 123 | for (CFIndex i = 0; i < entry->keysIndex; i++) 124 | keys[i] = elements[entry->keys[i]]; 125 | return keys; 126 | } 127 | 128 | inline __JSONStackRef __JSONStackCreate(CFAllocatorRef allocator, CFIndex initialSize) { 129 | __JSONStackRef stack = CFAllocatorAllocate(allocator, sizeof(__JSONStack), 0); 130 | if (stack) { 131 | stack->allocator = allocator ? CFRetain(allocator) : NULL; 132 | stack->retainCount = 1; 133 | stack->size = initialSize; 134 | stack->index = 0; 135 | stack->stack = CFAllocatorAllocate(stack->allocator, sizeof(__JSONStackEntryRef) * stack->size, 0); 136 | memset(stack->stack, 0, sizeof(__JSONStackEntryRef) * stack->size); 137 | } 138 | return stack; 139 | } 140 | 141 | inline __JSONStackRef __JSONStackRelease(__JSONStackRef stack) { 142 | if (stack) { 143 | if ( --stack->retainCount == 0) { 144 | CFAllocatorRef allocator = stack->allocator; 145 | if (stack->stack) { 146 | while (--stack->index >= 0) 147 | __JSONStackEntryRelease(stack->stack[stack->index]); 148 | if (stack->stack) 149 | CFAllocatorDeallocate(allocator, stack->stack); 150 | stack->stack = NULL; 151 | } 152 | CFAllocatorDeallocate(allocator, stack); 153 | stack = NULL; 154 | if (allocator) 155 | CFRelease(allocator); 156 | } 157 | } 158 | return stack; 159 | } 160 | 161 | inline __JSONStackEntryRef __JSONStackGetTop(__JSONStackRef stack) { 162 | if (stack->index > 0) 163 | return stack->stack[stack->index - 1]; 164 | else 165 | return NULL; 166 | } 167 | 168 | inline bool __JSONStackPush(__JSONStackRef stack, __JSONStackEntryRef entry) { 169 | bool success = 0; 170 | if (stack && entry) { 171 | 172 | // Do we need more space? Reallocate to 2 * current size. 173 | if (stack->index == stack->size) { 174 | CFIndex largerSize = stack->size ? stack->size << 1 : CORE_JSON_STACK_INITIAL_SIZE; 175 | __JSONStackEntryRef *largerStack = CFAllocatorReallocate(stack->allocator, stack->stack, sizeof(__JSONStackEntryRef) * largerSize, 0); 176 | if (largerStack) { 177 | stack->size = largerSize; 178 | stack->stack = largerStack; 179 | } 180 | } 181 | if (stack->index < stack->size) { 182 | stack->stack[stack->index++] = __JSONStackEntryRetain(entry); 183 | success = 1; 184 | } 185 | } 186 | return success; 187 | } 188 | 189 | // The caller is responsible for releasing returned __JSONStackEntryRef 190 | inline __JSONStackEntryRef __JSONStackPop(__JSONStackRef stack) { 191 | __JSONStackEntryRef entry = NULL; 192 | if (stack) { 193 | if (--stack->index >= 0) { 194 | entry = stack->stack[stack->index]; 195 | } else { 196 | // TODO: Out of bounds, this is error, should never happen 197 | } 198 | } 199 | return entry; 200 | } 201 | 202 | inline bool __JSONStackAppendValueAtTop(__JSONStackRef stack, CFIndex value) { 203 | return __JSONStackEntryAppendValue(__JSONStackGetTop(stack), value); 204 | } 205 | 206 | inline bool __JSONStackAppendKeyAtTop(__JSONStackRef stack, CFIndex key) { 207 | return __JSONStackEntryAppendKey(__JSONStackGetTop(stack), key); 208 | } 209 | 210 | #pragma Parser callbacks 211 | 212 | inline int __JSONParserAppendStringWithBytes(void *context, const unsigned char *value, size_t length) { 213 | __JSONRef json = (__JSONRef)context; 214 | __JSON_CONSUME_AND_RETURN(CFStringCreateWithBytes(json->allocator, value, length, kCFStringEncodingUTF8, 0)); 215 | } 216 | 217 | inline int __JSONParserAppendNull(void *context) { 218 | __JSONRef json = (__JSONRef)context; 219 | return __JSONStackAppendValueAtTop(json->stack, __JSONElementsAppend(json, kCFNull)); 220 | } 221 | 222 | inline int __JSONParserAppendBooleanWithInteger(void *context, int value) { 223 | __JSONRef json = (__JSONRef)context; 224 | return __JSONStackAppendValueAtTop(json->stack, __JSONElementsAppend(json, value ? kCFBooleanTrue : kCFBooleanFalse)); 225 | } 226 | 227 | inline int __JSONParserAppendNumberWithBytes(void *context, const char *value, size_t length) { 228 | __JSONRef json = (__JSONRef)context; 229 | CFNumberRef number = NULL; 230 | 231 | // TODO: How to do it better? Anybody? 232 | bool looksLikeFloat = 0; 233 | for (int i = 0; i < length; i++) 234 | if (value[i] == '.' || value[i] == 'e' || value[i] == 'E') 235 | looksLikeFloat = 1; 236 | 237 | if (looksLikeFloat) { 238 | double value_ = strtod((char *)value, NULL); 239 | number = CFNumberCreate(json->allocator, kCFNumberDoubleType, &value_); 240 | } else { 241 | long long value_ = strtoll((char *)value, NULL, 0); 242 | number = CFNumberCreate(json->allocator, kCFNumberLongLongType, &value_); 243 | } 244 | 245 | __JSON_CONSUME_AND_RETURN(number); 246 | } 247 | 248 | inline int __JSONParserAppendNumberWithLong(void *context, long value) { 249 | __JSONRef json = (__JSONRef)context; 250 | __JSON_CONSUME_AND_RETURN(CFNumberCreate(json->allocator, kCFNumberLongType, &value)); 251 | } 252 | 253 | inline int __JSONParserAppendNumberWithDouble(void *context, double value) { 254 | __JSONRef json = (__JSONRef)context; 255 | __JSON_CONSUME_AND_RETURN(CFNumberCreate(json->allocator, kCFNumberDoubleType, &value)); 256 | } 257 | 258 | // LOOK OUT! Appending to key array, not the value array 259 | inline int __JSONParserAppendMapKeyWithBytes(void *context, const unsigned char *value, size_t length) { 260 | __JSONRef json = (__JSONRef)context; 261 | CFTypeRef __json_element = CFStringCreateWithBytes(json->allocator, value, length, kCFStringEncodingUTF8, 0); 262 | int __json_return = __JSONStackAppendKeyAtTop(json->stack, __JSONElementsAppend(json, __json_element)); 263 | CFRelease(__json_element); 264 | return __json_return; 265 | } 266 | 267 | inline int __JSONParserAppendMapStart(void *context) { 268 | __JSONRef json = (__JSONRef)context; 269 | 270 | // Placeholder for the CFDictionaryRef which will be set when we get map end token 271 | CFIndex index = __JSONElementsAppend(json, kCFNull); 272 | 273 | // Add element to the parent container 274 | __JSONStackAppendValueAtTop(json->stack, index); 275 | 276 | // Push this element as the new container 277 | __JSONStackEntryRef entry = __JSONStackEntryCreate(json->allocator, index, CORE_JSON_STACK_ENTRY_VALUES_INITIAL_SIZE, CORE_JSON_STACK_ENTRY_KEYS_INITIAL_SIZE); 278 | __JSONStackPush(json->stack, entry); 279 | __JSONStackEntryRelease(entry); 280 | return 1; 281 | } 282 | 283 | inline int __JSONParserAppendMapEnd(void *context) { 284 | int success = 0; 285 | __JSONRef json = (__JSONRef)context; 286 | __JSONStackEntryRef entry = __JSONStackPop(json->stack); 287 | if (entry) { 288 | if (entry->keysIndex == entry->valuesIndex) { 289 | CFTypeRef *keys = __JSONStackEntryCreateKeys(entry, json->elements); 290 | if (keys) { 291 | CFTypeRef *values = __JSONStackEntryCreateValues(entry, json->elements); 292 | if (values) { 293 | json->elements[entry->index] = CFDictionaryCreate(json->allocator, keys, values, entry->keysIndex, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 294 | CFAllocatorDeallocate(entry->allocator, values); 295 | success = 1; 296 | } 297 | CFAllocatorDeallocate(entry->allocator, keys); 298 | } 299 | } else { 300 | // TODO: The number of keys and values does not match 301 | } 302 | __JSONStackEntryRelease(entry); 303 | } else { 304 | // TODO: Container on the stack can't be NULL (too deep?) 305 | } 306 | return success; 307 | } 308 | 309 | inline int __JSONParserAppendArrayStart(void *context) { 310 | __JSONRef json = (__JSONRef)context; 311 | 312 | // Placeholder for the CFArrayRef which will be set when we get array end token 313 | CFIndex index = __JSONElementsAppend(json, kCFNull); 314 | 315 | // Add element to the parent container 316 | __JSONStackAppendValueAtTop(json->stack, index); 317 | 318 | // Push this element as the new container 319 | __JSONStackEntryRef entry = __JSONStackEntryCreate(json->allocator, index, CORE_JSON_STACK_ENTRY_VALUES_INITIAL_SIZE, 0); 320 | __JSONStackPush(json->stack, entry); 321 | __JSONStackEntryRelease(entry); 322 | 323 | return 1; 324 | } 325 | 326 | inline int __JSONParserAppendArrayEnd(void *context) { 327 | int success = 0; 328 | __JSONRef json = (__JSONRef)context; 329 | __JSONStackEntryRef entry = __JSONStackPop(json->stack); 330 | if (entry) { 331 | CFTypeRef *values = __JSONStackEntryCreateValues(entry, json->elements); // TODO: change allocation to here. 332 | if (values) { 333 | json->elements[entry->index] = CFArrayCreate(json->allocator, values, entry->valuesIndex, &kCFTypeArrayCallBacks); 334 | CFAllocatorDeallocate(entry->allocator, values); 335 | success = 1; 336 | } 337 | __JSONStackEntryRelease(entry); 338 | } 339 | return success; 340 | } 341 | 342 | inline CFIndex __JSONElementsAppend(__JSONRef json, CFTypeRef value) { 343 | CFIndex index = json->elementsIndex; 344 | if (json->elementsIndex == json->elementsSize) { // Reallocate 345 | CFIndex largerSize = json->elementsSize ? json->elementsSize << 1 : CORE_JSON_ELEMENTS_INITIAL_SIZE; 346 | CFTypeRef *largerElements = CFAllocatorReallocate(json->allocator, json->elements, sizeof(CFTypeRef) * largerSize, 0); 347 | if (largerElements) { 348 | json->elementsSize = largerSize; 349 | json->elements = largerElements; 350 | } 351 | } 352 | if (json->elementsIndex < json->elementsSize) 353 | json->elements[json->elementsIndex++] = CFRetain(value); 354 | return index; 355 | } 356 | 357 | #pragma Memory allocation 358 | 359 | inline void *__JSONAllocatorAllocate(void *ctx, size_t sz) { 360 | return CFAllocatorAllocate(ctx, sz, 0); 361 | } 362 | 363 | inline void __JSONAllocatorDeallocate(void *ctx, void *ptr) { 364 | CFAllocatorDeallocate(ctx, ptr); 365 | } 366 | 367 | inline void *__JSONAllocatorReallocate(void *ctx, void *ptr, size_t sz) { 368 | return CFAllocatorReallocate(ctx, ptr, sz, 0); 369 | } 370 | 371 | inline __JSONRef __JSONCreate(CFAllocatorRef allocator, JSONReadOptions options) { 372 | __JSONRef json = CFAllocatorAllocate(allocator, sizeof(__JSON), 0); 373 | if (json) { 374 | json->allocator = allocator ? CFRetain(allocator) : NULL; 375 | json->retainCount = 1; 376 | 377 | json->yajlAllocFuncs.ctx = (void *)json->allocator; 378 | json->yajlAllocFuncs.malloc = __JSONAllocatorAllocate; 379 | json->yajlAllocFuncs.realloc = __JSONAllocatorReallocate; 380 | json->yajlAllocFuncs.free = __JSONAllocatorDeallocate; 381 | 382 | json->yajlParserCallbacks.yajl_null = __JSONParserAppendNull; 383 | json->yajlParserCallbacks.yajl_boolean = __JSONParserAppendBooleanWithInteger; 384 | 385 | // Set number or integer and double. Never all 3. 386 | json->yajlParserCallbacks.yajl_number = __JSONParserAppendNumberWithBytes; 387 | json->yajlParserCallbacks.yajl_integer = NULL; // __JSONParserAppendNumberWithLong 388 | json->yajlParserCallbacks.yajl_double = NULL; // __JSONParserAppendNumberWithDouble 389 | 390 | json->yajlParserCallbacks.yajl_start_map = __JSONParserAppendMapStart; 391 | json->yajlParserCallbacks.yajl_map_key = __JSONParserAppendMapKeyWithBytes; 392 | json->yajlParserCallbacks.yajl_end_map = __JSONParserAppendMapEnd; 393 | 394 | json->yajlParserCallbacks.yajl_start_array = __JSONParserAppendArrayStart; 395 | json->yajlParserCallbacks.yajl_end_array = __JSONParserAppendArrayEnd; 396 | 397 | json->yajlParserCallbacks.yajl_string = __JSONParserAppendStringWithBytes; 398 | 399 | json->elementsIndex = 0; 400 | json->elementsSize = CORE_JSON_ELEMENTS_INITIAL_SIZE; 401 | if (NULL == (json->elements = CFAllocatorAllocate(json->allocator, sizeof(CFTypeRef) * json->elementsSize, 0))) 402 | json = __JSONRelease(json); 403 | 404 | if (json) 405 | if (NULL == (json->stack = __JSONStackCreate(json->allocator, CORE_JSON_STACK_INITIAL_SIZE))) 406 | json = __JSONRelease(json); 407 | } 408 | return json; 409 | } 410 | 411 | inline __JSONRef __JSONRelease(__JSONRef json) { 412 | if (json) { 413 | if (--json->retainCount == 0) { 414 | CFAllocatorRef allocator = json->allocator; 415 | 416 | if (json->elements) { 417 | while (--json->elementsIndex >= 0) 418 | CFRelease(json->elements[json->elementsIndex]); 419 | CFAllocatorDeallocate(allocator, json->elements); 420 | } 421 | 422 | if (json->stack) 423 | json->stack = __JSONStackRelease(json->stack); 424 | 425 | CFAllocatorDeallocate(allocator, json); 426 | 427 | if (allocator) 428 | CFRelease(allocator); 429 | 430 | json = NULL; 431 | } 432 | } 433 | return json; 434 | } 435 | 436 | inline bool __JSONParseWithString(__JSONRef json, CFStringRef string, CFErrorRef *error) { 437 | bool success = 1; 438 | json->yajlParser = yajl_alloc(&json->yajlParserCallbacks, &json->yajlAllocFuncs, (void *)json); 439 | if (json->yajlParser) { 440 | // yajl_config(json->yajlParser, yajl_allow_comments, kJSONReadOptionAllowComments | options ? 1 : 0); 441 | // yajl_config(json->yajlParser, yajl_dont_validate_strings, kJSONReadOptionCheckUTF8 | options ? 1 : 0); 442 | 443 | CFDataRef data = CFStringCreateExternalRepresentation(json->allocator, string, kCFStringEncodingUTF8, 0); 444 | if (data) { 445 | if ((json->yajlParserStatus = yajl_parse(json->yajlParser, CFDataGetBytePtr(data), CFDataGetLength(data))) != yajl_status_ok) { 446 | if (error) { 447 | success = 0; 448 | 449 | unsigned char * str = yajl_get_error(json->yajlParser, 1, CFDataGetBytePtr(data), CFDataGetLength(data)); 450 | fprintf(stderr, "%s", (const char *) str); 451 | yajl_free_error(json->yajlParser, str); 452 | 453 | *error = CFErrorCreateWithUserInfoKeysAndValues(json->allocator, CFSTR("com.github.mirek.CoreJSON"), (CFIndex)json->yajlParserStatus, (const void *) { kCFErrorDescriptionKey }, (const void *) { CFSTR("Test") }, 1); 454 | } 455 | // TODO: Error stuff 456 | //printf("ERROR: %s\n", yajl_get_error(json->yajlParser, 1, __JSONUTF8StringGetBuffer(utf8), __JSONUTF8StringGetMaximumSize(utf8))); 457 | } 458 | 459 | json->yajlParserStatus = yajl_complete_parse(json->yajlParser); 460 | CFRelease(data); 461 | } else { 462 | success = 0; 463 | // TODO: data is 0 464 | } 465 | yajl_free(json->yajlParser); 466 | json->yajlParser = NULL; 467 | } else { 468 | 469 | // TODO: Couldn't allocate 470 | *error = CFErrorCreate(json->allocator, CFSTR("com.github.mirek.CoreJSON"), -1, NULL); 471 | success = 0; 472 | } 473 | 474 | return success; 475 | } 476 | 477 | inline CFTypeRef JSONCreateWithString(CFAllocatorRef allocator, CFStringRef string, JSONReadOptions options, CFErrorRef *error) { 478 | CFTypeRef result = NULL; 479 | __JSONRef json = NULL; 480 | if ((json = __JSONCreate(allocator, options))) { 481 | __JSONParseWithString(json, string, error); 482 | if ((result = __JSONCreateObject(json))) { 483 | // TODO: Set error 484 | } 485 | __JSONRelease(json); 486 | } 487 | return result; 488 | } 489 | 490 | inline CFTypeRef __JSONCreateObject(__JSONRef json) { 491 | return (json && json->elements && json->elementsIndex && *json->elements) ? CFRetain(*json->elements) : NULL; 492 | } 493 | 494 | #pragma Generator 495 | 496 | inline void __JSONGeneratorAppendString(CFAllocatorRef allocator, yajl_gen *g, CFStringRef value) { 497 | CFDataRef data = CFStringCreateExternalRepresentation(allocator, value, kCFStringEncodingUTF8, 0); 498 | if (data) { 499 | yajl_gen_string(*g, CFDataGetBytePtr(data), CFDataGetLength(data)); 500 | CFRelease(data); 501 | } else { 502 | // TODO: Error 503 | } 504 | } 505 | 506 | inline void __JSONGeneratorAppendDoubleTypeNumber(CFAllocatorRef allocator, yajl_gen *g, CFNumberRef value) { 507 | double value_ = 0.0; 508 | CFNumberGetValue(value, kCFNumberDoubleType, &value_); 509 | yajl_gen_double(*g, value_); 510 | } 511 | 512 | inline void __JSONGeneratorAppendLongLongTypeNumber(CFAllocatorRef allocator, yajl_gen *g, CFNumberRef value) { 513 | long long value_ = 0; 514 | CFNumberGetValue(value, kCFNumberLongLongType, &value_); 515 | char buffer[21]; // Maximum string length is "±9223372036854775807\0" 516 | int length = sprintf(buffer, "%lld", value_); 517 | yajl_gen_number(*g, buffer, length); 518 | } 519 | 520 | inline void __JSONGeneratorAppendNumber(CFAllocatorRef allocator, yajl_gen *g, CFNumberRef value) { 521 | if (CFNumberIsFloatType(value)) 522 | __JSONGeneratorAppendDoubleTypeNumber(allocator, g, value); 523 | else 524 | __JSONGeneratorAppendLongLongTypeNumber(allocator, g, value); 525 | } 526 | 527 | inline void __JSONGeneratorAppendArray(CFAllocatorRef allocator, yajl_gen *g, CFArrayRef value) { 528 | yajl_gen_array_open(*g); 529 | CFIndex n = CFArrayGetCount(value); 530 | CFTypeRef *values = CFAllocatorAllocate(allocator, sizeof(CFTypeRef) * n, 0); 531 | CFArrayGetValues(value, CFRangeMake(0, n), values); 532 | for (CFIndex i = 0; i < n; i++) 533 | __JSONGeneratorAppendValue(allocator, g, values[i]); 534 | CFAllocatorDeallocate(allocator, values); 535 | yajl_gen_array_close(*g); 536 | } 537 | 538 | inline void __JSONGeneratorAppendDictionary(CFAllocatorRef allocator, yajl_gen *g, CFDictionaryRef value) { 539 | yajl_gen_map_open(*g); 540 | CFIndex n = CFDictionaryGetCount(value); 541 | CFTypeRef *keys = CFAllocatorAllocate(allocator, sizeof(CFTypeRef) * n, 0); 542 | CFTypeRef *values = CFAllocatorAllocate(allocator, sizeof(CFTypeRef) * n, 0); 543 | CFDictionaryGetKeysAndValues(value, keys, values); 544 | for (CFIndex i = 0; i < n; i++) { 545 | __JSONGeneratorAppendValue(allocator, g, keys[i]); // TODO: append as string 546 | __JSONGeneratorAppendValue(allocator, g, values[i]); 547 | } 548 | CFAllocatorDeallocate(allocator, values); 549 | CFAllocatorDeallocate(allocator, keys); 550 | yajl_gen_map_close(*g); 551 | } 552 | 553 | inline void __JSONGeneratorAppendAttributedString(CFAllocatorRef allocator, yajl_gen *g, CFAttributedStringRef value) { 554 | __JSONGeneratorAppendString(allocator, g, CFAttributedStringGetString(value)); 555 | } 556 | 557 | inline void __JSONGeneratorAppendBoolean(CFAllocatorRef allocator, yajl_gen *g, CFBooleanRef value) { 558 | yajl_gen_bool(*g, CFBooleanGetValue(value)); 559 | } 560 | 561 | inline void __JSONGeneratorAppendNull(CFAllocatorRef allocator, yajl_gen *g, CFNullRef value) { 562 | yajl_gen_null(*g); 563 | } 564 | 565 | inline void __JSONGeneratorAppendURL(CFAllocatorRef allocator, yajl_gen *g, CFURLRef value) { 566 | __JSONGeneratorAppendString(allocator, g, CFURLGetString(value)); 567 | } 568 | 569 | inline void __JSONGeneratorAppendUUID(CFAllocatorRef allocator, yajl_gen *g, CFUUIDRef value) { 570 | CFStringRef string = CFUUIDCreateString(allocator, value); 571 | __JSONGeneratorAppendString(allocator, g, string); 572 | CFRelease(string); 573 | } 574 | 575 | inline void __JSONGeneratorAppendValue(CFAllocatorRef allocator, yajl_gen *g, CFTypeRef value) { 576 | if (value) { 577 | CFTypeID typeID = CFGetTypeID(value); 578 | if (typeID == CFStringGetTypeID()) __JSONGeneratorAppendString (allocator, g, value); 579 | else if (typeID == CFNumberGetTypeID()) __JSONGeneratorAppendNumber (allocator, g, value); 580 | else if (typeID == CFArrayGetTypeID()) __JSONGeneratorAppendArray (allocator, g, value); 581 | else if (typeID == CFDictionaryGetTypeID()) __JSONGeneratorAppendDictionary (allocator, g, value); 582 | else if (typeID == CFAttributedStringGetTypeID()) __JSONGeneratorAppendAttributedString (allocator, g, value); 583 | // else if (typeID == CFBagGetTypeID()) __JSONGeneratorAppendBag (allocator, g, value); 584 | // else if (typeID == CFBinaryHeapGetTypeID()) __JSONGeneratorAppendBinaryHeap (allocator, g, value); 585 | // else if (typeID == CFBitVectorGetTypeID()) __JSONGeneratorAppendBitVector (allocator, g, value); 586 | else if (typeID == CFBooleanGetTypeID()) __JSONGeneratorAppendBoolean (allocator, g, value); 587 | // else if (typeID == CFDataGetTypeID()) __JSONGeneratorAppendData (allocator, g, value); 588 | // else if (typeID == CFDateGetTypeID()) __JSONGeneratorAppendDate (allocator, g, value); 589 | else if (typeID == CFNullGetTypeID()) __JSONGeneratorAppendNull (allocator, g, value); 590 | // else if (typeID == CFSetGetTypeID()) __JSONGeneratorAppendSet (allocator, g, value); 591 | // else if (typeID == CFTreeGetTypeID()) __JSONGeneratorAppendTree (allocator, g, value); 592 | else if (typeID == CFURLGetTypeID()) __JSONGeneratorAppendURL (allocator, g, value); 593 | else if (typeID == CFUUIDGetTypeID()) __JSONGeneratorAppendUUID (allocator, g, value); 594 | } 595 | } 596 | 597 | inline CFStringRef JSONCreateString(CFAllocatorRef allocator, CFTypeRef value, JSONWriteOptions options, CFErrorRef *error) { 598 | yajl_alloc_funcs yajlAllocFuncs; 599 | yajlAllocFuncs.ctx = (void *)allocator; 600 | yajlAllocFuncs.malloc = __JSONAllocatorAllocate; 601 | yajlAllocFuncs.free = __JSONAllocatorDeallocate; 602 | yajlAllocFuncs.realloc = __JSONAllocatorReallocate; 603 | // yajl_gen_config yajlGenConfig; 604 | // yajlGenConfig.beautify = options | kJSONWriteOptionIndent ? 1 : 0; 605 | // yajlGenConfig.indentString = options | kJSONWriteOptionIndent ? " " : 0; 606 | yajl_gen yajlGen = yajl_gen_alloc(&yajlAllocFuncs); 607 | __JSONGeneratorAppendValue(allocator, &yajlGen, value); 608 | const unsigned char *buffer = NULL; 609 | size_t length = 0; 610 | switch (yajl_gen_get_buf(yajlGen, &buffer, &length)) { 611 | case yajl_gen_status_ok: // no error 612 | break; 613 | 614 | case yajl_gen_keys_must_be_strings: // at a point where a map key is generated, a function other than yajl_gen_string was called 615 | break; 616 | 617 | case yajl_max_depth_exceeded: // YAJL's maximum generation depth was exceeded. See YAJL_MAX_DEPTH 618 | break; 619 | 620 | case yajl_gen_in_error_state: // A generator function (yajl_gen_XXX) was called while in an error state 621 | break; 622 | 623 | case yajl_gen_generation_complete: // A complete JSON document has been generated 624 | break; 625 | 626 | case yajl_gen_invalid_number: // yajl_gen_double was passed an invalid floating point value (infinity or NaN) 627 | break; 628 | 629 | case yajl_gen_invalid_string: // returned from yajl_gen_string() when the yajl_gen_validate_utf8 option is enabled and an invalid was passed by client code. 630 | break; 631 | 632 | case yajl_gen_no_buf: // A print callback was passed in, so there is no internal buffer to get from 633 | break; 634 | } 635 | 636 | // TODO: If buffer is not null and length > 0, otherwise empty string. 637 | CFStringRef string = CFStringCreateWithBytes(allocator, buffer, length, kCFStringEncodingUTF8, 0); 638 | 639 | yajl_gen_clear(yajlGen); 640 | yajl_gen_free(yajlGen); 641 | 642 | return string; 643 | } 644 | -------------------------------------------------------------------------------- /CoreJSON/CoreJSON.h: -------------------------------------------------------------------------------- 1 | // 2 | // CoreJSON.h 3 | // CoreJSON Framework 4 | // 5 | // Copyright 2011 Mirek Rusin 6 | // http://github.com/mirek/CoreJSON 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #define CORE_JSON_STACK_INITIAL_SIZE YAJL_MAX_DEPTH 26 | #define CORE_JSON_STACK_ENTRY_KEYS_INITIAL_SIZE 1024 27 | #define CORE_JSON_STACK_ENTRY_VALUES_INITIAL_SIZE 1024 28 | #define CORE_JSON_ELEMENTS_INITIAL_SIZE 4096 29 | 30 | #pragma Helper stack for parsing 31 | 32 | // Internal stack to hold containers when parsing. Practically all functions in most 33 | // cases are O(1), unless internal buffers are full and need to be reallocated. 34 | // 35 | // This stucture is also used to create CFArrayRef for arrays and CFDictionaryRef for 36 | // maps by a single create call. 37 | typedef struct { 38 | CFAllocatorRef allocator; 39 | CFIndex retainCount; 40 | 41 | CFIndex index; 42 | 43 | CFIndex *values; 44 | CFIndex valuesIndex; 45 | CFIndex valuesSize; 46 | 47 | CFIndex *keys; 48 | CFIndex keysIndex; 49 | CFIndex keysSize; 50 | } __JSONStackEntry; 51 | 52 | typedef __JSONStackEntry *__JSONStackEntryRef; 53 | 54 | __JSONStackEntryRef __JSONStackEntryCreate (CFAllocatorRef allocator, CFIndex index, CFIndex valuesInitialSize, CFIndex keysInitialSize); 55 | __JSONStackEntryRef __JSONStackEntryRetain (__JSONStackEntryRef entry); 56 | CFIndex __JSONStackEntryRelease (__JSONStackEntryRef entry); 57 | bool __JSONStackEntryAppendValue (__JSONStackEntryRef entry, CFIndex value); 58 | bool __JSONStackEntryAppendKey (__JSONStackEntryRef entry, CFIndex key); 59 | CFTypeRef *__JSONStackEntryCreateValues (__JSONStackEntryRef entry, CFTypeRef *elements); 60 | CFTypeRef *__JSONStackEntryCreateKeys (__JSONStackEntryRef entry, CFTypeRef *elements); 61 | 62 | typedef struct { 63 | CFAllocatorRef allocator; 64 | CFIndex retainCount; 65 | __JSONStackEntryRef *stack; 66 | CFIndex index; 67 | CFIndex size; 68 | } __JSONStack; 69 | 70 | typedef __JSONStack *__JSONStackRef; 71 | 72 | __JSONStackRef __JSONStackCreate (CFAllocatorRef allocator, CFIndex initialSize); 73 | __JSONStackRef __JSONStackRelease (__JSONStackRef stack); 74 | __JSONStackEntryRef __JSONStackGetTop (__JSONStackRef stack); 75 | bool __JSONStackPush (__JSONStackRef stack, __JSONStackEntryRef entry); 76 | __JSONStackEntryRef __JSONStackPop (__JSONStackRef stack); 77 | bool __JSONStackAppendValueAtTop (__JSONStackRef stack, CFIndex value); 78 | bool __JSONStackAppendKeyAtTop (__JSONStackRef stack, CFIndex key); 79 | 80 | #pragma Internal callbacks for libyajl parser 81 | 82 | int __JSONParserAppendStringWithBytes (void *context, const unsigned char *value, size_t length); 83 | int __JSONParserAppendNull (void *context); 84 | int __JSONParserAppendBooleanWithInteger (void *context, int value); 85 | int __JSONParserAppendNumberWithBytes (void *context, const char *value, size_t length); 86 | int __JSONParserAppendNumberWithLong (void *context, long value); 87 | int __JSONParserAppendNumberWithDouble (void *context, double value); 88 | int __JSONParserAppendMapKeyWithBytes (void *context, const unsigned char *value, size_t length); 89 | int __JSONParserAppendMapStart (void *context); 90 | int __JSONParserAppendMapEnd (void *context); 91 | int __JSONParserAppendArrayStart (void *context); 92 | int __JSONParserAppendArrayEnd (void *context); 93 | 94 | #pragma Internal memory allocation 95 | 96 | void *__JSONAllocatorAllocate (void *ctx, size_t sz); 97 | void __JSONAllocatorDeallocate (void *ctx, void *ptr); 98 | void *__JSONAllocatorReallocate (void *ctx, void *ptr, size_t sz); 99 | 100 | typedef struct { 101 | CFAllocatorRef allocator; 102 | CFIndex retainCount; 103 | 104 | yajl_handle yajlParser; 105 | // yajl_parser_config yajlParserConfig; 106 | yajl_status yajlParserStatus; 107 | yajl_callbacks yajlParserCallbacks; 108 | yajl_alloc_funcs yajlAllocFuncs; 109 | 110 | CFIndex elementsIndex; 111 | CFIndex elementsSize; 112 | CFTypeRef *elements; 113 | 114 | __JSONStackRef stack; 115 | 116 | } __JSON; 117 | 118 | typedef __JSON *__JSONRef; 119 | 120 | typedef enum JSONReadOptions { 121 | kJSONReadOptionCheckUTF8 = 1, 122 | kJSONReadOptionAllowComments = 2, 123 | 124 | kJSONReadOptionsDefault = 0, 125 | kJSONReadOptionsCheckUTF8AndAllowComments = 3 126 | } JSONReadOptions; 127 | 128 | typedef enum JSONWriteOptions { 129 | kJSONWriteOptionIndent = 1, 130 | 131 | kJSONWriteOptionsDefault = 0 132 | } JSONWriteOptions; 133 | 134 | #pragma Internal elements array support 135 | 136 | CFIndex __JSONElementsAppend (__JSONRef json, CFTypeRef value); 137 | 138 | #pragma Generator 139 | 140 | void __JSONGeneratorAppendString (CFAllocatorRef allocator, yajl_gen *g, CFStringRef value); 141 | void __JSONGeneratorAppendDoubleTypeNumber (CFAllocatorRef allocator, yajl_gen *g, CFNumberRef value); 142 | void __JSONGeneratorAppendLongLongTypeNumber (CFAllocatorRef allocator, yajl_gen *g, CFNumberRef value); 143 | void __JSONGeneratorAppendNumber (CFAllocatorRef allocator, yajl_gen *g, CFNumberRef value); 144 | void __JSONGeneratorAppendArray (CFAllocatorRef allocator, yajl_gen *g, CFArrayRef value); 145 | void __JSONGeneratorAppendDictionary (CFAllocatorRef allocator, yajl_gen *g, CFDictionaryRef value); 146 | void __JSONGeneratorAppendValue (CFAllocatorRef allocator, yajl_gen *g, CFTypeRef value); 147 | void __JSONGeneratorAppendAttributedString (CFAllocatorRef allocator, yajl_gen *g, CFAttributedStringRef value); 148 | void __JSONGeneratorAppendBoolean (CFAllocatorRef allocator, yajl_gen *g, CFBooleanRef value); 149 | void __JSONGeneratorAppendNull (CFAllocatorRef allocator, yajl_gen *g, CFNullRef value); 150 | void __JSONGeneratorAppendURL (CFAllocatorRef allocator, yajl_gen *g, CFURLRef value); 151 | void __JSONGeneratorAppendUUID (CFAllocatorRef allocator, yajl_gen *g, CFUUIDRef value); 152 | 153 | __JSONRef __JSONCreate (CFAllocatorRef allocator, JSONReadOptions options); 154 | bool __JSONParseWithString (__JSONRef json, CFStringRef string, CFErrorRef *error); 155 | CFTypeRef __JSONCreateObject (__JSONRef json); 156 | __JSONRef __JSONRelease (__JSONRef json); 157 | 158 | #pragma Public API 159 | 160 | CFTypeRef JSONCreateWithString(CFAllocatorRef allocator, CFStringRef string, JSONReadOptions options, CFErrorRef *error); 161 | //CFTypeRef JSONCreateWithData (CFAllocatorRef allocator, CFDataRef data); 162 | 163 | CFStringRef JSONCreateString(CFAllocatorRef allocator, CFTypeRef value, JSONWriteOptions options, CFErrorRef *error); 164 | //CFDataRef JSONCreateData (CFAllocatorRef allocator, CFTypeRef value); 165 | -------------------------------------------------------------------------------- /CoreJSON/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CoreJSONTests/CoreJSONTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.github.mirek.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CoreJSONTests/CoreJSONTests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'CoreJSONTests' target in the 'CoreJSONTests' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /CoreJSONTests/CoreJSONTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // CoreJSONTests.h 3 | // CoreJSON Framework 4 | // 5 | // Copyright 2011 Mirek Rusin 6 | // http://github.com/mirek/CoreJSON 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #import 22 | #import "CoreJSON.h" 23 | #import "time.h" 24 | #import "CoreTestAllocator.h" 25 | 26 | #define MAX_FRAMES 100 27 | 28 | //void demangle(const char* symbol) { 29 | // size_t size; 30 | // int status; 31 | // char temp[128]; 32 | // char* demangled; 33 | // //first, try to demangle a c++ name 34 | // if (1 == sscanf(symbol, "%*[^(]%*[^_]%127[^)+]", temp)) { 35 | // if (NULL != (demangled = abi::__cxa_demangle(temp, NULL, &size, &status))) { 36 | // std::string result(demangled); 37 | // free(demangled); 38 | // return result; 39 | // } 40 | // } 41 | // //if that didn't work, try to get a regular c symbol 42 | // if (1 == sscanf(symbol, "%127s", temp)) { 43 | // return temp; 44 | // } 45 | // 46 | // //if all else fails, just return the symbol 47 | // return symbol; 48 | //} 49 | 50 | @interface CoreJSONTests : SenTestCase { 51 | @private 52 | CFAllocatorRef testAllocator; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /CoreJSONTests/CoreJSONTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CoreJSONTests.m 3 | // CoreJSON Framework 4 | // 5 | // Copyright 2011 Mirek Rusin 6 | // http://github.com/mirek/CoreJSON 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #import "CoreJSONTests.h" 22 | 23 | @implementation CoreJSONTests 24 | 25 | - (void) setUp { 26 | [super setUp]; 27 | testAllocator = TestAllocatorCreate(); 28 | } 29 | 30 | - (void) tearDown { 31 | STAssertTrue(TestAllocatorGetAllocationsCount(testAllocator) > 0, @"Allocations count should be more than 0"); 32 | STAssertTrue(TestAllocatorGetDeallocationsCount(testAllocator) > 0, @"Deallocations count should be more than 0"); 33 | STAssertEquals(TestAllocatorGetAllocationsCount(testAllocator), TestAllocatorGetDeallocationsCount(testAllocator), @"Allocations/deallocations mismatch"); 34 | 35 | if (TestAllocatorGetAllocationsCount(testAllocator) != TestAllocatorGetDeallocationsCount(testAllocator)) 36 | TestAllocatorPrintAddressesAndBacktraces(testAllocator); 37 | 38 | CFRelease(testAllocator); 39 | [super tearDown]; 40 | } 41 | 42 | - (void) testGenerator { 43 | CFUUIDRef uuid = CFUUIDCreate(NULL); 44 | id object = [[NSDictionary alloc] initWithObjectsAndKeys: 45 | [NSNumber numberWithLongLong: 9223372036854775807], @"number", 46 | uuid, @"uuid", 47 | nil]; 48 | NSError *error = nil; 49 | NSString *json = (NSString *)JSONCreateString(testAllocator, object, kJSONWriteOptionsDefault, (CFErrorRef *)&error); 50 | STAssertTrue([json length] > 0, @"Generated string should have length > 0"); 51 | [object release]; 52 | [json release]; 53 | [error release]; 54 | CFRelease(uuid); 55 | } 56 | 57 | - (void) testSimpleStuff { 58 | { 59 | NSError *error = nil; 60 | NSArray *array = (NSArray *)JSONCreateWithString(testAllocator, (CFStringRef)@"[1, 3, 5]", kJSONReadOptionsDefault, (CFErrorRef *)&error); 61 | STAssertNil(error, @"Error should be nil"); 62 | STAssertNotNil(array, @"Should be array but have nil"); 63 | STAssertTrue([array count] == 3, @"Array should have 3 elements"); 64 | STAssertTrue([[NSNumber numberWithInt: 1] isEqualToNumber: [array objectAtIndex: 0]], @"First element should be 1"); 65 | STAssertTrue([[NSNumber numberWithInt: 3] isEqualToNumber: [array objectAtIndex: 1]], @"Second element should be 3"); 66 | STAssertTrue([[NSNumber numberWithInt: 5] isEqualToNumber: [array objectAtIndex: 2]], @"Third element should be 5"); 67 | [error release]; 68 | [array release]; 69 | } 70 | { 71 | NSError *error = nil; 72 | NSDictionary *dictionary = (NSDictionary *)JSONCreateWithString(testAllocator, (CFStringRef)@"{ \"a\": 1, \"b\": 3, \"c\": 5 }", kJSONReadOptionsDefault, (CFErrorRef *)&error); 73 | STAssertNil(error, @"Error should be nil"); 74 | STAssertNotNil(dictionary, @"Should be dictionary but have nil"); 75 | STAssertTrue([dictionary count] == 3, @"Dictionary should have 3 entries"); 76 | STAssertTrue([[dictionary objectForKey: @"b"] isEqualToNumber: [NSNumber numberWithInt: 3]], @"'b' value should be 3"); 77 | [error release]; 78 | [dictionary release]; 79 | } 80 | } 81 | 82 | - (void) testUTF8Strings { 83 | { 84 | NSError *error = nil; 85 | NSArray *array = (NSArray *)JSONCreateWithString(testAllocator, (CFStringRef)@"[\"a’la\"]", kJSONReadOptionsDefault, (CFErrorRef *)&error); 86 | STAssertNil(error, @"Error should be nil"); 87 | STAssertNotNil(array, @"Should be array but have nil"); 88 | STAssertTrue([array count] == 1, @"Array should have 1 element"); 89 | STAssertTrue([[array objectAtIndex: 0] isEqualToString: @"a’la"], @"UTF8 string a’la expected"); 90 | [error release]; 91 | [array release]; 92 | } 93 | } 94 | 95 | - (void) testLargeNumbers { 96 | { 97 | NSError *error = nil; 98 | NSArray *array = (NSArray *)JSONCreateWithString(testAllocator, (CFStringRef)@"[4294967297, 9223372036854775807, -9223372036854775807]", kJSONReadOptionsDefault, (CFErrorRef *)&error); 99 | STAssertTrue([array count] == 3, @"Array should have 3 elements"); 100 | STAssertEquals([[array objectAtIndex: 0] longLongValue], 4294967297, @"Large number 2^32+1 expected"); 101 | STAssertEquals([[array objectAtIndex: 1] longLongValue], 9223372036854775807, @"Large number 2^(64-1) expected"); 102 | STAssertEquals([[array objectAtIndex: 2] longLongValue], -9223372036854775807, @"Large number 2^(64-1) expected"); 103 | [error release]; 104 | [array release]; 105 | } 106 | } 107 | 108 | - (void) __testFloats { 109 | { 110 | NSError *error = nil; 111 | NSArray *array = (NSArray *)JSONCreateWithString(testAllocator, (CFStringRef)@"[3.14159265, 1.61803399, -57.2957795]", kJSONReadOptionsDefault, (CFErrorRef *)&error); 112 | STAssertTrue([array count] == 3, @"Array should have 3 elements"); 113 | STAssertEquals([[array objectAtIndex: 0] doubleValue], 3.14159265, @"Large number 2^32+1 expected"); 114 | STAssertEquals([[array objectAtIndex: 1] doubleValue], 1.61803399, @"Large number 2^(64-1) expected"); 115 | STAssertEquals([[array objectAtIndex: 2] doubleValue], -57.2957795, @"Large number 2^(64-1) expected"); 116 | [error release]; 117 | [array release]; 118 | } 119 | } 120 | 121 | @end 122 | -------------------------------------------------------------------------------- /CoreJSONTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # CoreJSON Framework 2 | 3 | CoreJSON is iOS and OSX Core Foundation based fast parser and generator based on `libyajl` C library. 4 | 5 | Comparison with other JSON frameworks: 6 | 7 | ![Chart](http://chart.apis.google.com/chart?chf=bg,s,67676700&chxl=1:|TouchJSON|JSON+Framework|YAJL|Apple+JSON|CoreJSON|JSONKit&chxr=0,0,60&chxt=x,y&chbh=a&chs=300x165&cht=bhg&chco=94AAC8&chds=0,237.904&chd=t:46.582,63.192,128.143,129.231,154.504,237.904&chtt=1+Iteration%2C+iPhone+4+iOS+4.2.1) 8 | 9 | _Tests performed with https://github.com/samsoffes/json-benchmarks_ 10 | 11 | ## Usage 12 | 13 | Parsing in Objective-C: 14 | 15 | NSError *error = nil; 16 | id object = (id)JSONCreateWithString(NULL, (CFStringRef)@"[foo, bar]", kJSONReadOptionsDefault, (CFErrorRef *)&error); 17 | if (object) { 18 | // Do something with object (NSArray) 19 | [object release]; 20 | } 21 | 22 | Parsing in C: 23 | 24 | CFErrorRef error = NULL; 25 | CFTypeRef object = JSONCreateWithString(NULL, CFSTR("[foo, bar]"), kJSONReadOptionsDefault, &error); 26 | if (object) { 27 | // Do something with object 28 | CFRelease(object); 29 | } 30 | 31 | Generating in Objective-C: 32 | 33 | NSArray *array = [NSArray arrayWithObjects: @"foo", @"bar", nil]; 34 | NSError *error = nil; 35 | NSString *json = (id)JSONCreateString(NULL, array, kJSONWriteOptionsDefault, (CFErrorRef *)&error); 36 | if (json) { 37 | // Do something with json string 38 | [json release]; 39 | } 40 | [array release]; 41 | 42 | Generating in C: 43 | 44 | CFTypeRef values[] = { CFSTR("foo"), CFSTR("bar") }; 45 | CFArrayRef array = CFArrayCreateMutable(NULL, values, 2, &kCFTypeArrayCallBacks); 46 | CFErrorRef error = NULL; 47 | CFStringRef json = JSONCreateString(NULL, array, kJSONWriteOptionsDefault, &error); 48 | if (json) { 49 | // Do something with json string 50 | CFRelease(json); 51 | } 52 | CFRelease(array); 53 | 54 | _You should also take care of `error` object_ 55 | 56 | ## Options 57 | 58 | `JSONReadOptions`: 59 | 60 | * `kJSONReadOptionCheckUTF8 = 1` -- Check UTF8 strings 61 | * `kJSONReadOptionAllowComments = 2` -- Allow `/* comments */` 62 | * `kJSONReadOptionsDefault = 0` -- Default options (don't check UTF8 strings and do not allow comments) 63 | * `kJSONReadOptionsCheckUTF8AndAllowComments = 3` -- Check UTF8 strings and allow comments 64 | 65 | `JSONWriteOptions`: 66 | 67 | * `kJSONWriteOptionIndent = 1` -- Indent generated JSON string 68 | * `kJSONWriteOptionsDefault = 0` -- Default options (do not indent JSON string) 69 | 70 | ## Using in your projects 71 | 72 | There are just 2 files `CoreJSON.h` and `CoreJSON.c` you'll need together with `libyajl`. 73 | 74 | For your own (non Mac AppStore) OSX projects the quick way is to: 75 | 76 | 1. `brew install yajl` 77 | 2. add `/usr/local/lib` to `Library Search Path` and `/usr/local/include` to `Header Search Path` 78 | 3. Just drop `CoreJSON.h` and `CoreJSON.c` to your project and have fun 79 | 80 | For OSX and iOS (Mac AppStore/AppStore) projects you need to include `libyajl` and drop `CoreJSON.h` and `CoreJSON.c` files to your project. 81 | One way to do it: 82 | 83 | 1. Go to your project's directory (for which you're using `git`, right? ;) and `git submodule add git://github.com/mirek/CoreJSON.git CoreJSON` 84 | 2. From Xcode add `CoreJSON.h` and `CoreJSON.c` files to your project 85 | 3. If you're already using `libyajl` in your project, you are good to go. If not, add `libyajl` files 86 | 87 | ## License 88 | 89 | The MIT License 90 | 91 | Copyright 2011 Mirek Rusin 92 | http://github.com/mirek/CoreJSON 93 | 94 | Permission to use, copy, modify, and/or distribute this software for any 95 | purpose with or without fee is hereby granted, provided that the above 96 | copyright notice and this permission notice appear in all copies. 97 | 98 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 99 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 100 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 101 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 102 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 103 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 104 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 105 | -------------------------------------------------------------------------------- /YAJL.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | EB59CC381376FE6D00C02960 /* yajl_tree.c in Sources */ = {isa = PBXBuildFile; fileRef = EB59CC371376FE6D00C02960 /* yajl_tree.c */; }; 11 | EB59CC391376FE6D00C02960 /* yajl_tree.c in Sources */ = {isa = PBXBuildFile; fileRef = EB59CC371376FE6D00C02960 /* yajl_tree.c */; }; 12 | EBB1AE181312B0F0006476A7 /* yajl_alloc.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE0A1312B0EF006476A7 /* yajl_alloc.c */; }; 13 | EBB1AE191312B0F0006476A7 /* yajl_alloc.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB1AE0B1312B0EF006476A7 /* yajl_alloc.h */; }; 14 | EBB1AE1A1312B0F0006476A7 /* yajl_buf.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE0C1312B0EF006476A7 /* yajl_buf.c */; }; 15 | EBB1AE1B1312B0F0006476A7 /* yajl_buf.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB1AE0D1312B0EF006476A7 /* yajl_buf.h */; }; 16 | EBB1AE1C1312B0F0006476A7 /* yajl_bytestack.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB1AE0E1312B0EF006476A7 /* yajl_bytestack.h */; }; 17 | EBB1AE1D1312B0F0006476A7 /* yajl_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE0F1312B0EF006476A7 /* yajl_encode.c */; }; 18 | EBB1AE1E1312B0F0006476A7 /* yajl_encode.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB1AE101312B0EF006476A7 /* yajl_encode.h */; }; 19 | EBB1AE1F1312B0F0006476A7 /* yajl_gen.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE111312B0EF006476A7 /* yajl_gen.c */; }; 20 | EBB1AE201312B0F0006476A7 /* yajl_lex.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE121312B0EF006476A7 /* yajl_lex.c */; }; 21 | EBB1AE211312B0F0006476A7 /* yajl_lex.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB1AE131312B0EF006476A7 /* yajl_lex.h */; }; 22 | EBB1AE221312B0F0006476A7 /* yajl_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE141312B0EF006476A7 /* yajl_parser.c */; }; 23 | EBB1AE231312B0F0006476A7 /* yajl_parser.h in Headers */ = {isa = PBXBuildFile; fileRef = EBB1AE151312B0F0006476A7 /* yajl_parser.h */; }; 24 | EBB1AE241312B0F0006476A7 /* yajl_version.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE161312B0F0006476A7 /* yajl_version.c */; }; 25 | EBB1AE251312B0F0006476A7 /* yajl.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE171312B0F0006476A7 /* yajl.c */; }; 26 | EBB1AE621312B3EE006476A7 /* yajl_alloc.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE0A1312B0EF006476A7 /* yajl_alloc.c */; }; 27 | EBB1AE631312B3EF006476A7 /* yajl_buf.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE0C1312B0EF006476A7 /* yajl_buf.c */; }; 28 | EBB1AE641312B3F2006476A7 /* yajl_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE0F1312B0EF006476A7 /* yajl_encode.c */; }; 29 | EBB1AE651312B3FA006476A7 /* yajl_gen.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE111312B0EF006476A7 /* yajl_gen.c */; }; 30 | EBB1AE661312B3FD006476A7 /* yajl_lex.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE121312B0EF006476A7 /* yajl_lex.c */; }; 31 | EBB1AE671312B400006476A7 /* yajl_parser.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE141312B0EF006476A7 /* yajl_parser.c */; }; 32 | EBB1AE681312B403006476A7 /* yajl_version.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE161312B0F0006476A7 /* yajl_version.c */; }; 33 | EBB1AE691312B406006476A7 /* yajl.c in Sources */ = {isa = PBXBuildFile; fileRef = EBB1AE171312B0F0006476A7 /* yajl.c */; }; 34 | /* End PBXBuildFile section */ 35 | 36 | /* Begin PBXFileReference section */ 37 | EB59CC371376FE6D00C02960 /* yajl_tree.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_tree.c; path = yajl/src/yajl_tree.c; sourceTree = ""; }; 38 | EBB1ADF01312AD72006476A7 /* libYAJL (iOS).a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libYAJL (iOS).a"; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | EBB1ADF71312AD72006476A7 /* YAJL-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "YAJL-Prefix.pch"; sourceTree = ""; }; 40 | EBB1AE0A1312B0EF006476A7 /* yajl_alloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_alloc.c; path = yajl/src/yajl_alloc.c; sourceTree = ""; }; 41 | EBB1AE0B1312B0EF006476A7 /* yajl_alloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_alloc.h; path = yajl/src/yajl_alloc.h; sourceTree = ""; }; 42 | EBB1AE0C1312B0EF006476A7 /* yajl_buf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_buf.c; path = yajl/src/yajl_buf.c; sourceTree = ""; }; 43 | EBB1AE0D1312B0EF006476A7 /* yajl_buf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_buf.h; path = yajl/src/yajl_buf.h; sourceTree = ""; }; 44 | EBB1AE0E1312B0EF006476A7 /* yajl_bytestack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_bytestack.h; path = yajl/src/yajl_bytestack.h; sourceTree = ""; }; 45 | EBB1AE0F1312B0EF006476A7 /* yajl_encode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_encode.c; path = yajl/src/yajl_encode.c; sourceTree = ""; }; 46 | EBB1AE101312B0EF006476A7 /* yajl_encode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_encode.h; path = yajl/src/yajl_encode.h; sourceTree = ""; }; 47 | EBB1AE111312B0EF006476A7 /* yajl_gen.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_gen.c; path = yajl/src/yajl_gen.c; sourceTree = ""; }; 48 | EBB1AE121312B0EF006476A7 /* yajl_lex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_lex.c; path = yajl/src/yajl_lex.c; sourceTree = ""; }; 49 | EBB1AE131312B0EF006476A7 /* yajl_lex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_lex.h; path = yajl/src/yajl_lex.h; sourceTree = ""; }; 50 | EBB1AE141312B0EF006476A7 /* yajl_parser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_parser.c; path = yajl/src/yajl_parser.c; sourceTree = ""; }; 51 | EBB1AE151312B0F0006476A7 /* yajl_parser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = yajl_parser.h; path = yajl/src/yajl_parser.h; sourceTree = ""; }; 52 | EBB1AE161312B0F0006476A7 /* yajl_version.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl_version.c; path = yajl/src/yajl_version.c; sourceTree = ""; }; 53 | EBB1AE171312B0F0006476A7 /* yajl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = yajl.c; path = yajl/src/yajl.c; sourceTree = ""; }; 54 | EBB1AE491312B33C006476A7 /* YAJL.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = YAJL.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | EBB1ADED1312AD72006476A7 /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | EBB1AE451312B33C006476A7 /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | EBB1ADE51312AD72006476A7 = { 76 | isa = PBXGroup; 77 | children = ( 78 | EBB1ADF51312AD72006476A7 /* YAJL */, 79 | EBB1ADF21312AD72006476A7 /* Frameworks */, 80 | EBB1ADF11312AD72006476A7 /* Products */, 81 | ); 82 | sourceTree = ""; 83 | }; 84 | EBB1ADF11312AD72006476A7 /* Products */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | EBB1ADF01312AD72006476A7 /* libYAJL (iOS).a */, 88 | EBB1AE491312B33C006476A7 /* YAJL.framework */, 89 | ); 90 | name = Products; 91 | sourceTree = ""; 92 | }; 93 | EBB1ADF21312AD72006476A7 /* Frameworks */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | ); 97 | name = Frameworks; 98 | sourceTree = ""; 99 | }; 100 | EBB1ADF51312AD72006476A7 /* YAJL */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | EBB1AE0A1312B0EF006476A7 /* yajl_alloc.c */, 104 | EBB1AE0B1312B0EF006476A7 /* yajl_alloc.h */, 105 | EBB1AE0C1312B0EF006476A7 /* yajl_buf.c */, 106 | EBB1AE0D1312B0EF006476A7 /* yajl_buf.h */, 107 | EBB1AE0E1312B0EF006476A7 /* yajl_bytestack.h */, 108 | EBB1AE0F1312B0EF006476A7 /* yajl_encode.c */, 109 | EBB1AE101312B0EF006476A7 /* yajl_encode.h */, 110 | EBB1AE111312B0EF006476A7 /* yajl_gen.c */, 111 | EBB1AE121312B0EF006476A7 /* yajl_lex.c */, 112 | EBB1AE131312B0EF006476A7 /* yajl_lex.h */, 113 | EBB1AE141312B0EF006476A7 /* yajl_parser.c */, 114 | EBB1AE151312B0F0006476A7 /* yajl_parser.h */, 115 | EB59CC371376FE6D00C02960 /* yajl_tree.c */, 116 | EBB1AE161312B0F0006476A7 /* yajl_version.c */, 117 | EBB1AE171312B0F0006476A7 /* yajl.c */, 118 | EBB1ADF61312AD72006476A7 /* Supporting Files */, 119 | ); 120 | path = YAJL; 121 | sourceTree = ""; 122 | }; 123 | EBB1ADF61312AD72006476A7 /* Supporting Files */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | EBB1ADF71312AD72006476A7 /* YAJL-Prefix.pch */, 127 | ); 128 | name = "Supporting Files"; 129 | sourceTree = ""; 130 | }; 131 | /* End PBXGroup section */ 132 | 133 | /* Begin PBXHeadersBuildPhase section */ 134 | EBB1ADEE1312AD72006476A7 /* Headers */ = { 135 | isa = PBXHeadersBuildPhase; 136 | buildActionMask = 2147483647; 137 | files = ( 138 | EBB1AE191312B0F0006476A7 /* yajl_alloc.h in Headers */, 139 | EBB1AE1B1312B0F0006476A7 /* yajl_buf.h in Headers */, 140 | EBB1AE1C1312B0F0006476A7 /* yajl_bytestack.h in Headers */, 141 | EBB1AE1E1312B0F0006476A7 /* yajl_encode.h in Headers */, 142 | EBB1AE211312B0F0006476A7 /* yajl_lex.h in Headers */, 143 | EBB1AE231312B0F0006476A7 /* yajl_parser.h in Headers */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | EBB1AE461312B33C006476A7 /* Headers */ = { 148 | isa = PBXHeadersBuildPhase; 149 | buildActionMask = 2147483647; 150 | files = ( 151 | ); 152 | runOnlyForDeploymentPostprocessing = 0; 153 | }; 154 | /* End PBXHeadersBuildPhase section */ 155 | 156 | /* Begin PBXNativeTarget section */ 157 | EBB1ADEF1312AD72006476A7 /* YAJL (iOS) */ = { 158 | isa = PBXNativeTarget; 159 | buildConfigurationList = EBB1ADFA1312AD72006476A7 /* Build configuration list for PBXNativeTarget "YAJL (iOS)" */; 160 | buildPhases = ( 161 | EBB1ADEC1312AD72006476A7 /* Sources */, 162 | EBB1ADED1312AD72006476A7 /* Frameworks */, 163 | EBB1ADEE1312AD72006476A7 /* Headers */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | ); 169 | name = "YAJL (iOS)"; 170 | productName = YAJL; 171 | productReference = EBB1ADF01312AD72006476A7 /* libYAJL (iOS).a */; 172 | productType = "com.apple.product-type.library.static"; 173 | }; 174 | EBB1AE481312B33C006476A7 /* YAJL */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = EBB1AE591312B33C006476A7 /* Build configuration list for PBXNativeTarget "YAJL" */; 177 | buildPhases = ( 178 | EBB1AE441312B33C006476A7 /* Sources */, 179 | EBB1AE451312B33C006476A7 /* Frameworks */, 180 | EBB1AE461312B33C006476A7 /* Headers */, 181 | EBB1AE471312B33C006476A7 /* Resources */, 182 | ); 183 | buildRules = ( 184 | ); 185 | dependencies = ( 186 | ); 187 | name = YAJL; 188 | productName = YAJL; 189 | productReference = EBB1AE491312B33C006476A7 /* YAJL.framework */; 190 | productType = "com.apple.product-type.framework"; 191 | }; 192 | /* End PBXNativeTarget section */ 193 | 194 | /* Begin PBXProject section */ 195 | EBB1ADE71312AD72006476A7 /* Project object */ = { 196 | isa = PBXProject; 197 | attributes = { 198 | ORGANIZATIONNAME = "Inteliv Ltd"; 199 | }; 200 | buildConfigurationList = EBB1ADEA1312AD72006476A7 /* Build configuration list for PBXProject "YAJL" */; 201 | compatibilityVersion = "Xcode 3.2"; 202 | developmentRegion = English; 203 | hasScannedForEncodings = 0; 204 | knownRegions = ( 205 | en, 206 | ); 207 | mainGroup = EBB1ADE51312AD72006476A7; 208 | productRefGroup = EBB1ADF11312AD72006476A7 /* Products */; 209 | projectDirPath = ""; 210 | projectRoot = ""; 211 | targets = ( 212 | EBB1ADEF1312AD72006476A7 /* YAJL (iOS) */, 213 | EBB1AE481312B33C006476A7 /* YAJL */, 214 | ); 215 | }; 216 | /* End PBXProject section */ 217 | 218 | /* Begin PBXResourcesBuildPhase section */ 219 | EBB1AE471312B33C006476A7 /* Resources */ = { 220 | isa = PBXResourcesBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | ); 224 | runOnlyForDeploymentPostprocessing = 0; 225 | }; 226 | /* End PBXResourcesBuildPhase section */ 227 | 228 | /* Begin PBXSourcesBuildPhase section */ 229 | EBB1ADEC1312AD72006476A7 /* Sources */ = { 230 | isa = PBXSourcesBuildPhase; 231 | buildActionMask = 2147483647; 232 | files = ( 233 | EBB1AE181312B0F0006476A7 /* yajl_alloc.c in Sources */, 234 | EBB1AE1A1312B0F0006476A7 /* yajl_buf.c in Sources */, 235 | EBB1AE1D1312B0F0006476A7 /* yajl_encode.c in Sources */, 236 | EBB1AE1F1312B0F0006476A7 /* yajl_gen.c in Sources */, 237 | EBB1AE201312B0F0006476A7 /* yajl_lex.c in Sources */, 238 | EBB1AE221312B0F0006476A7 /* yajl_parser.c in Sources */, 239 | EBB1AE241312B0F0006476A7 /* yajl_version.c in Sources */, 240 | EBB1AE251312B0F0006476A7 /* yajl.c in Sources */, 241 | EB59CC381376FE6D00C02960 /* yajl_tree.c in Sources */, 242 | ); 243 | runOnlyForDeploymentPostprocessing = 0; 244 | }; 245 | EBB1AE441312B33C006476A7 /* Sources */ = { 246 | isa = PBXSourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | EBB1AE621312B3EE006476A7 /* yajl_alloc.c in Sources */, 250 | EBB1AE631312B3EF006476A7 /* yajl_buf.c in Sources */, 251 | EBB1AE641312B3F2006476A7 /* yajl_encode.c in Sources */, 252 | EBB1AE651312B3FA006476A7 /* yajl_gen.c in Sources */, 253 | EBB1AE661312B3FD006476A7 /* yajl_lex.c in Sources */, 254 | EBB1AE671312B400006476A7 /* yajl_parser.c in Sources */, 255 | EBB1AE681312B403006476A7 /* yajl_version.c in Sources */, 256 | EBB1AE691312B406006476A7 /* yajl.c in Sources */, 257 | EB59CC391376FE6D00C02960 /* yajl_tree.c in Sources */, 258 | ); 259 | runOnlyForDeploymentPostprocessing = 0; 260 | }; 261 | /* End PBXSourcesBuildPhase section */ 262 | 263 | /* Begin XCBuildConfiguration section */ 264 | EBB1ADF81312AD72006476A7 /* Debug */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 268 | GCC_C_LANGUAGE_STANDARD = gnu99; 269 | GCC_OPTIMIZATION_LEVEL = 0; 270 | GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 271 | GCC_VERSION = com.apple.compilers.llvmgcc42; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 273 | GCC_WARN_UNUSED_VARIABLE = YES; 274 | IPHONEOS_DEPLOYMENT_TARGET = 4.2; 275 | SDKROOT = iphoneos; 276 | }; 277 | name = Debug; 278 | }; 279 | EBB1ADF91312AD72006476A7 /* Release */ = { 280 | isa = XCBuildConfiguration; 281 | buildSettings = { 282 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 283 | GCC_C_LANGUAGE_STANDARD = gnu99; 284 | GCC_VERSION = com.apple.compilers.llvmgcc42; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 286 | GCC_WARN_UNUSED_VARIABLE = YES; 287 | IPHONEOS_DEPLOYMENT_TARGET = 4.2; 288 | SDKROOT = iphoneos; 289 | }; 290 | name = Release; 291 | }; 292 | EBB1ADFB1312AD72006476A7 /* Debug */ = { 293 | isa = XCBuildConfiguration; 294 | buildSettings = { 295 | ALWAYS_SEARCH_USER_PATHS = NO; 296 | DSTROOT = /tmp/YAJL.dst; 297 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 298 | GCC_PREFIX_HEADER = "YAJL/YAJL-Prefix.pch"; 299 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 300 | OTHER_LDFLAGS = "-ObjC"; 301 | PRODUCT_NAME = "$(TARGET_NAME)"; 302 | }; 303 | name = Debug; 304 | }; 305 | EBB1ADFC1312AD72006476A7 /* Release */ = { 306 | isa = XCBuildConfiguration; 307 | buildSettings = { 308 | ALWAYS_SEARCH_USER_PATHS = NO; 309 | DSTROOT = /tmp/YAJL.dst; 310 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 311 | GCC_PREFIX_HEADER = "YAJL/YAJL-Prefix.pch"; 312 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 313 | OTHER_LDFLAGS = "-ObjC"; 314 | PRODUCT_NAME = "$(TARGET_NAME)"; 315 | }; 316 | name = Release; 317 | }; 318 | EBB1AE571312B33C006476A7 /* Debug */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | ALWAYS_SEARCH_USER_PATHS = NO; 322 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 323 | COPY_PHASE_STRIP = NO; 324 | DYLIB_COMPATIBILITY_VERSION = 1; 325 | DYLIB_CURRENT_VERSION = 1; 326 | FRAMEWORK_VERSION = A; 327 | GCC_DYNAMIC_NO_PIC = NO; 328 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 329 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 330 | GCC_PREFIX_HEADER = "YAJL/YAJL-Prefix.pch"; 331 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 332 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 333 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 334 | INFOPLIST_FILE = "YAJL/YAJL-Info.plist"; 335 | MACOSX_DEPLOYMENT_TARGET = 10.6; 336 | ONLY_ACTIVE_ARCH = YES; 337 | PRODUCT_NAME = "$(TARGET_NAME)"; 338 | SDKROOT = macosx; 339 | WRAPPER_EXTENSION = framework; 340 | }; 341 | name = Debug; 342 | }; 343 | EBB1AE581312B33C006476A7 /* Release */ = { 344 | isa = XCBuildConfiguration; 345 | buildSettings = { 346 | ALWAYS_SEARCH_USER_PATHS = NO; 347 | ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; 348 | COPY_PHASE_STRIP = YES; 349 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 350 | DYLIB_COMPATIBILITY_VERSION = 1; 351 | DYLIB_CURRENT_VERSION = 1; 352 | FRAMEWORK_VERSION = A; 353 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 354 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 355 | GCC_PREFIX_HEADER = "YAJL/YAJL-Prefix.pch"; 356 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 357 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 358 | HEADER_SEARCH_PATHS = "\"$(SRCROOT)/YAJL/include\""; 359 | INFOPLIST_FILE = "YAJL/YAJL-Info.plist"; 360 | MACOSX_DEPLOYMENT_TARGET = 10.6; 361 | PRODUCT_NAME = "$(TARGET_NAME)"; 362 | SDKROOT = macosx; 363 | WRAPPER_EXTENSION = framework; 364 | }; 365 | name = Release; 366 | }; 367 | /* End XCBuildConfiguration section */ 368 | 369 | /* Begin XCConfigurationList section */ 370 | EBB1ADEA1312AD72006476A7 /* Build configuration list for PBXProject "YAJL" */ = { 371 | isa = XCConfigurationList; 372 | buildConfigurations = ( 373 | EBB1ADF81312AD72006476A7 /* Debug */, 374 | EBB1ADF91312AD72006476A7 /* Release */, 375 | ); 376 | defaultConfigurationIsVisible = 0; 377 | defaultConfigurationName = Release; 378 | }; 379 | EBB1ADFA1312AD72006476A7 /* Build configuration list for PBXNativeTarget "YAJL (iOS)" */ = { 380 | isa = XCConfigurationList; 381 | buildConfigurations = ( 382 | EBB1ADFB1312AD72006476A7 /* Debug */, 383 | EBB1ADFC1312AD72006476A7 /* Release */, 384 | ); 385 | defaultConfigurationIsVisible = 0; 386 | defaultConfigurationName = Release; 387 | }; 388 | EBB1AE591312B33C006476A7 /* Build configuration list for PBXNativeTarget "YAJL" */ = { 389 | isa = XCConfigurationList; 390 | buildConfigurations = ( 391 | EBB1AE571312B33C006476A7 /* Debug */, 392 | EBB1AE581312B33C006476A7 /* Release */, 393 | ); 394 | defaultConfigurationIsVisible = 0; 395 | defaultConfigurationName = Release; 396 | }; 397 | /* End XCConfigurationList section */ 398 | }; 399 | rootObject = EBB1ADE71312AD72006476A7 /* Project object */; 400 | } 401 | -------------------------------------------------------------------------------- /YAJL.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YAJL/YAJL-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.github.mirek.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | NSHumanReadableCopyright 26 | Copyright © 2011 Inteliv Ltd. All rights reserved. 27 | NSPrincipalClass 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /YAJL/YAJL-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'YAJL' target in the 'YAJL' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | // #import 7 | #endif 8 | -------------------------------------------------------------------------------- /YAJL/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /YAJL/include/yajl/yajl_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2011, Lloyd Hilaiel 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #ifndef __YAJL_COMMON_H__ 18 | #define __YAJL_COMMON_H__ 19 | 20 | #include 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | #define YAJL_MAX_DEPTH 128 27 | 28 | /* msft dll export gunk. To build a DLL on windows, you 29 | * must define WIN32, YAJL_SHARED, and YAJL_BUILD. To use a shared 30 | * DLL, you must define YAJL_SHARED and WIN32 */ 31 | #if defined(WIN32) && defined(YAJL_SHARED) 32 | # ifdef YAJL_BUILD 33 | # define YAJL_API __declspec(dllexport) 34 | # else 35 | # define YAJL_API __declspec(dllimport) 36 | # endif 37 | #else 38 | # if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 39 | # define YAJL_API __attribute__ ((visibility("default"))) 40 | # else 41 | # define YAJL_API 42 | # endif 43 | #endif 44 | 45 | /** pointer to a malloc function, supporting client overriding memory 46 | * allocation routines */ 47 | typedef void * (*yajl_malloc_func)(void *ctx, size_t sz); 48 | 49 | /** pointer to a free function, supporting client overriding memory 50 | * allocation routines */ 51 | typedef void (*yajl_free_func)(void *ctx, void * ptr); 52 | 53 | /** pointer to a realloc function which can resize an allocation. */ 54 | typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, size_t sz); 55 | 56 | /** A structure which can be passed to yajl_*_alloc routines to allow the 57 | * client to specify memory allocation functions to be used. */ 58 | typedef struct 59 | { 60 | /** pointer to a function that can allocate uninitialized memory */ 61 | yajl_malloc_func malloc; 62 | /** pointer to a function that can resize memory allocations */ 63 | yajl_realloc_func realloc; 64 | /** pointer to a function that can free memory allocated using 65 | * reallocFunction or mallocFunction */ 66 | yajl_free_func free; 67 | /** a context pointer that will be passed to above allocation routines */ 68 | void * ctx; 69 | } yajl_alloc_funcs; 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /YAJL/include/yajl/yajl_gen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2011, Lloyd Hilaiel 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | /** 18 | * \file yajl_gen.h 19 | * Interface to YAJL's JSON generation facilities. 20 | */ 21 | 22 | #include 23 | 24 | #ifndef __YAJL_GEN_H__ 25 | #define __YAJL_GEN_H__ 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | /** generator status codes */ 33 | typedef enum { 34 | /** no error */ 35 | yajl_gen_status_ok = 0, 36 | /** at a point where a map key is generated, a function other than 37 | * yajl_gen_string was called */ 38 | yajl_gen_keys_must_be_strings, 39 | /** YAJL's maximum generation depth was exceeded. see 40 | * YAJL_MAX_DEPTH */ 41 | yajl_max_depth_exceeded, 42 | /** A generator function (yajl_gen_XXX) was called while in an error 43 | * state */ 44 | yajl_gen_in_error_state, 45 | /** A complete JSON document has been generated */ 46 | yajl_gen_generation_complete, 47 | /** yajl_gen_double was passed an invalid floating point value 48 | * (infinity or NaN). */ 49 | yajl_gen_invalid_number, 50 | /** A print callback was passed in, so there is no internal 51 | * buffer to get from */ 52 | yajl_gen_no_buf, 53 | /** returned from yajl_gen_string() when the yajl_gen_validate_utf8 54 | * option is enabled and an invalid was passed by client code. 55 | */ 56 | yajl_gen_invalid_string 57 | } yajl_gen_status; 58 | 59 | /** an opaque handle to a generator */ 60 | typedef struct yajl_gen_t * yajl_gen; 61 | 62 | /** a callback used for "printing" the results. */ 63 | typedef void (*yajl_print_t)(void * ctx, 64 | const char * str, 65 | size_t len); 66 | 67 | /** configuration parameters for the parser, these may be passed to 68 | * yajl_gen_config() along with option specific argument(s). In general, 69 | * all configuration parameters default to *off*. */ 70 | typedef enum { 71 | /** generate indented (beautiful) output */ 72 | yajl_gen_beautify = 0x01, 73 | /** 74 | * Set an indent string which is used when yajl_gen_beautify 75 | * is enabled. Maybe something like \\t or some number of 76 | * spaces. The default is four spaces ' '. 77 | */ 78 | yajl_gen_indent_string = 0x02, 79 | /** 80 | * Set a function and context argument that should be used to 81 | * output generated json. the function should conform to the 82 | * yajl_print_t prototype while the context argument is a 83 | * void * of your choosing. 84 | * 85 | * example: 86 | * yajl_gen_config(g, yajl_gen_print_callback, myFunc, myVoidPtr); 87 | */ 88 | yajl_gen_print_callback = 0x04, 89 | /** 90 | * Normally the generator does not validate that strings you 91 | * pass to it via yajl_gen_string() are valid UTF8. Enabling 92 | * this option will cause it to do so. 93 | */ 94 | yajl_gen_validate_utf8 = 0x08, 95 | /** 96 | * the forward solidus (slash or '/' in human) is not required to be 97 | * escaped in json text. By default, YAJL will not escape it in the 98 | * iterest of saving bytes. Setting this flag will cause YAJL to 99 | * always escape '/' in generated JSON strings. 100 | */ 101 | yajl_gen_escape_solidus = 0x10 102 | } yajl_gen_option; 103 | 104 | /** allow the modification of generator options subsequent to handle 105 | * allocation (via yajl_alloc) 106 | * \returns zero in case of errors, non-zero otherwise 107 | */ 108 | YAJL_API int yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...); 109 | 110 | /** allocate a generator handle 111 | * \param allocFuncs an optional pointer to a structure which allows 112 | * the client to overide the memory allocation 113 | * used by yajl. May be NULL, in which case 114 | * malloc/free/realloc will be used. 115 | * 116 | * \returns an allocated handle on success, NULL on failure (bad params) 117 | */ 118 | YAJL_API yajl_gen yajl_gen_alloc(const yajl_alloc_funcs * allocFuncs); 119 | 120 | /** free a generator handle */ 121 | YAJL_API void yajl_gen_free(yajl_gen handle); 122 | 123 | YAJL_API yajl_gen_status yajl_gen_integer(yajl_gen hand, long long int number); 124 | /** generate a floating point number. number may not be infinity or 125 | * NaN, as these have no representation in JSON. In these cases the 126 | * generator will return 'yajl_gen_invalid_number' */ 127 | YAJL_API yajl_gen_status yajl_gen_double(yajl_gen hand, double number); 128 | YAJL_API yajl_gen_status yajl_gen_number(yajl_gen hand, 129 | const char * num, 130 | size_t len); 131 | YAJL_API yajl_gen_status yajl_gen_string(yajl_gen hand, 132 | const unsigned char * str, 133 | size_t len); 134 | YAJL_API yajl_gen_status yajl_gen_null(yajl_gen hand); 135 | YAJL_API yajl_gen_status yajl_gen_bool(yajl_gen hand, int boolean); 136 | YAJL_API yajl_gen_status yajl_gen_map_open(yajl_gen hand); 137 | YAJL_API yajl_gen_status yajl_gen_map_close(yajl_gen hand); 138 | YAJL_API yajl_gen_status yajl_gen_array_open(yajl_gen hand); 139 | YAJL_API yajl_gen_status yajl_gen_array_close(yajl_gen hand); 140 | 141 | /** access the null terminated generator buffer. If incrementally 142 | * outputing JSON, one should call yajl_gen_clear to clear the 143 | * buffer. This allows stream generation. */ 144 | YAJL_API yajl_gen_status yajl_gen_get_buf(yajl_gen hand, 145 | const unsigned char ** buf, 146 | size_t * len); 147 | 148 | /** clear yajl's output buffer, but maintain all internal generation 149 | * state. This function will not "reset" the generator state, and is 150 | * intended to enable incremental JSON outputing. */ 151 | YAJL_API void yajl_gen_clear(yajl_gen hand); 152 | 153 | #ifdef __cplusplus 154 | } 155 | #endif 156 | 157 | #endif 158 | -------------------------------------------------------------------------------- /YAJL/include/yajl/yajl_parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2007-2011, Lloyd Hilaiel 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | /** 18 | * \file yajl_parse.h 19 | * Interface to YAJL's JSON stream parsing facilities. 20 | */ 21 | 22 | #include 23 | 24 | #ifndef __YAJL_PARSE_H__ 25 | #define __YAJL_PARSE_H__ 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | /** error codes returned from this interface */ 33 | typedef enum { 34 | /** no error was encountered */ 35 | yajl_status_ok, 36 | /** a client callback returned zero, stopping the parse */ 37 | yajl_status_client_canceled, 38 | /** An error occured during the parse. Call yajl_get_error for 39 | * more information about the encountered error */ 40 | yajl_status_error 41 | } yajl_status; 42 | 43 | /** attain a human readable, english, string for an error */ 44 | YAJL_API const char * yajl_status_to_string(yajl_status code); 45 | 46 | /** an opaque handle to a parser */ 47 | typedef struct yajl_handle_t * yajl_handle; 48 | 49 | /** yajl is an event driven parser. this means as json elements are 50 | * parsed, you are called back to do something with the data. The 51 | * functions in this table indicate the various events for which 52 | * you will be called back. Each callback accepts a "context" 53 | * pointer, this is a void * that is passed into the yajl_parse 54 | * function which the client code may use to pass around context. 55 | * 56 | * All callbacks return an integer. If non-zero, the parse will 57 | * continue. If zero, the parse will be canceled and 58 | * yajl_status_client_canceled will be returned from the parse. 59 | * 60 | * \attention { 61 | * A note about the handling of numbers: 62 | * 63 | * yajl will only convert numbers that can be represented in a 64 | * double or a 64 bit (long long) int. All other numbers will 65 | * be passed to the client in string form using the yajl_number 66 | * callback. Furthermore, if yajl_number is not NULL, it will 67 | * always be used to return numbers, that is yajl_integer and 68 | * yajl_double will be ignored. If yajl_number is NULL but one 69 | * of yajl_integer or yajl_double are defined, parsing of a 70 | * number larger than is representable in a double or 64 bit 71 | * integer will result in a parse error. 72 | * } 73 | */ 74 | typedef struct { 75 | int (* yajl_null)(void * ctx); 76 | int (* yajl_boolean)(void * ctx, int boolVal); 77 | int (* yajl_integer)(void * ctx, long long integerVal); 78 | int (* yajl_double)(void * ctx, double doubleVal); 79 | /** A callback which passes the string representation of the number 80 | * back to the client. Will be used for all numbers when present */ 81 | int (* yajl_number)(void * ctx, const char * numberVal, 82 | size_t numberLen); 83 | 84 | /** strings are returned as pointers into the JSON text when, 85 | * possible, as a result, they are _not_ null padded */ 86 | int (* yajl_string)(void * ctx, const unsigned char * stringVal, 87 | size_t stringLen); 88 | 89 | int (* yajl_start_map)(void * ctx); 90 | int (* yajl_map_key)(void * ctx, const unsigned char * key, 91 | size_t stringLen); 92 | int (* yajl_end_map)(void * ctx); 93 | 94 | int (* yajl_start_array)(void * ctx); 95 | int (* yajl_end_array)(void * ctx); 96 | } yajl_callbacks; 97 | 98 | /** allocate a parser handle 99 | * \param callbacks a yajl callbacks structure specifying the 100 | * functions to call when different JSON entities 101 | * are encountered in the input text. May be NULL, 102 | * which is only useful for validation. 103 | * \param afs memory allocation functions, may be NULL for to use 104 | * C runtime library routines (malloc and friends) 105 | * \param ctx a context pointer that will be passed to callbacks. 106 | */ 107 | YAJL_API yajl_handle yajl_alloc(const yajl_callbacks * callbacks, 108 | yajl_alloc_funcs * afs, 109 | void * ctx); 110 | 111 | 112 | /** configuration parameters for the parser, these may be passed to 113 | * yajl_config() along with option specific argument(s). In general, 114 | * all configuration parameters default to *off*. */ 115 | typedef enum { 116 | /** Ignore javascript style comments present in 117 | * JSON input. Non-standard, but rather fun 118 | * arguments: toggled off with integer zero, on otherwise. 119 | * 120 | * example: 121 | * yajl_config(h, yajl_allow_comments, 1); // turn comment support on 122 | */ 123 | yajl_allow_comments = 0x01, 124 | /** 125 | * When set the parser will verify that all strings in JSON input are 126 | * valid UTF8 and will emit a parse error if this is not so. When set, 127 | * this option makes parsing slightly more expensive (~7% depending 128 | * on processor and compiler in use) 129 | * 130 | * example: 131 | * yajl_config(h, yajl_dont_validate_strings, 1); // disable utf8 checking 132 | */ 133 | yajl_dont_validate_strings = 0x02, 134 | /** 135 | * By default, upon calls to yajl_complete_parse(), yajl will 136 | * ensure the entire input text was consumed and will raise an error 137 | * otherwise. Enabling this flag will cause yajl to disable this 138 | * check. This can be useful when parsing json out of a that contains more 139 | * than a single JSON document. 140 | */ 141 | yajl_allow_trailing_garbage = 0x04, 142 | /** 143 | * Allow multiple values to be parsed by a single handle. The 144 | * entire text must be valid JSON, and values can be seperated 145 | * by any kind of whitespace. This flag will change the 146 | * behavior of the parser, and cause it continue parsing after 147 | * a value is parsed, rather than transitioning into a 148 | * complete state. This option can be useful when parsing multiple 149 | * values from an input stream. 150 | */ 151 | yajl_allow_multiple_values = 0x08, 152 | /** 153 | * When yajl_complete_parse() is called the parser will 154 | * check that the top level value was completely consumed. I.E., 155 | * if called whilst in the middle of parsing a value 156 | * yajl will enter an error state (premature EOF). Setting this 157 | * flag suppresses that check and the corresponding error. 158 | */ 159 | yajl_allow_partial_values = 0x10 160 | } yajl_option; 161 | 162 | /** allow the modification of parser options subsequent to handle 163 | * allocation (via yajl_alloc) 164 | * \returns zero in case of errors, non-zero otherwise 165 | */ 166 | YAJL_API int yajl_config(yajl_handle h, yajl_option opt, ...); 167 | 168 | /** free a parser handle */ 169 | YAJL_API void yajl_free(yajl_handle handle); 170 | 171 | /** Parse some json! 172 | * \param hand - a handle to the json parser allocated with yajl_alloc 173 | * \param jsonText - a pointer to the UTF8 json text to be parsed 174 | * \param jsonTextLength - the length, in bytes, of input text 175 | */ 176 | YAJL_API yajl_status yajl_parse(yajl_handle hand, 177 | const unsigned char * jsonText, 178 | size_t jsonTextLength); 179 | 180 | /** Parse any remaining buffered json. 181 | * Since yajl is a stream-based parser, without an explicit end of 182 | * input, yajl sometimes can't decide if content at the end of the 183 | * stream is valid or not. For example, if "1" has been fed in, 184 | * yajl can't know whether another digit is next or some character 185 | * that would terminate the integer token. 186 | * 187 | * \param hand - a handle to the json parser allocated with yajl_alloc 188 | */ 189 | YAJL_API yajl_status yajl_complete_parse(yajl_handle hand); 190 | 191 | /** get an error string describing the state of the 192 | * parse. 193 | * 194 | * If verbose is non-zero, the message will include the JSON 195 | * text where the error occured, along with an arrow pointing to 196 | * the specific char. 197 | * 198 | * \returns A dynamically allocated string will be returned which should 199 | * be freed with yajl_free_error 200 | */ 201 | YAJL_API unsigned char * yajl_get_error(yajl_handle hand, int verbose, 202 | const unsigned char * jsonText, 203 | size_t jsonTextLength); 204 | 205 | /** 206 | * get the amount of data consumed from the last chunk passed to YAJL. 207 | * 208 | * In the case of a successful parse this can help you understand if 209 | * the entire buffer was consumed (which will allow you to handle 210 | * "junk at end of input"). 211 | * 212 | * In the event an error is encountered during parsing, this function 213 | * affords the client a way to get the offset into the most recent 214 | * chunk where the error occured. 0 will be returned if no error 215 | * was encountered. 216 | */ 217 | YAJL_API size_t yajl_get_bytes_consumed(yajl_handle hand); 218 | 219 | /** free an error returned from yajl_get_error */ 220 | YAJL_API void yajl_free_error(yajl_handle hand, unsigned char * str); 221 | 222 | #ifdef __cplusplus 223 | } 224 | #endif 225 | 226 | #endif 227 | -------------------------------------------------------------------------------- /YAJL/include/yajl/yajl_tree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2011 Florian Forster 3 | * 4 | * Permission to use, copy, modify, and/or distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | /** 18 | * \file yajl_tree.h 19 | * 20 | * Parses JSON data and returns the data in tree form. 21 | * 22 | * \author Florian Forster 23 | * \date August 2010 24 | * 25 | * This interface makes quick parsing and extraction of 26 | * smallish JSON docs trivial: 27 | * 28 | * \include example/parse_config.c 29 | */ 30 | 31 | #ifndef YAJL_TREE_H 32 | #define YAJL_TREE_H 1 33 | 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** possible data types that a yajl_val_s can hold */ 41 | typedef enum { 42 | yajl_t_string = 1, 43 | yajl_t_number = 2, 44 | yajl_t_object = 3, 45 | yajl_t_array = 4, 46 | yajl_t_true = 5, 47 | yajl_t_false = 6, 48 | yajl_t_null = 7, 49 | /** The any type isn't valid for yajl_val_s.type, but can be 50 | * used as an argument to routines like yajl_tree_get(). 51 | */ 52 | yajl_t_any = 8 53 | } yajl_type; 54 | 55 | #define YAJL_NUMBER_INT_VALID 0x01 56 | #define YAJL_NUMBER_DOUBLE_VALID 0x02 57 | 58 | /** A pointer to a node in the parse tree */ 59 | typedef struct yajl_val_s * yajl_val; 60 | 61 | /** 62 | * A JSON value representation capable of holding one of the seven 63 | * types above. For "string", "number", "object", and "array" 64 | * additional data is available in the union. The "YAJL_IS_*" 65 | * and "YAJL_GET_*" macros below allow type checking and convenient 66 | * value extraction. 67 | */ 68 | struct yajl_val_s 69 | { 70 | /** Type of the value contained. Use the "YAJL_IS_*" macors to check for a 71 | * specific type. */ 72 | yajl_type type; 73 | /** Type-specific data. You may use the "YAJL_GET_*" macros to access these 74 | * members. */ 75 | union 76 | { 77 | char * string; 78 | struct { 79 | long long i; /*< integer value, if representable. */ 80 | double d; /*< double value, if representable. */ 81 | /** Signals whether the \em i and \em d members are 82 | * valid. See \c YAJL_NUMBER_INT_VALID and 83 | * \c YAJL_NUMBER_DOUBLE_VALID. */ 84 | char *r; /*< unparsed number in string form. */ 85 | unsigned int flags; 86 | } number; 87 | struct { 88 | const char **keys; /*< Array of keys */ 89 | yajl_val *values; /*< Array of values. */ 90 | size_t len; /*< Number of key-value-pairs. */ 91 | } object; 92 | struct { 93 | yajl_val *values; /*< Array of elements. */ 94 | size_t len; /*< Number of elements. */ 95 | } array; 96 | } u; 97 | }; 98 | 99 | /** 100 | * Parse a string. 101 | * 102 | * Parses an null-terminated string containing JSON data and returns a pointer 103 | * to the top-level value (root of the parse tree). 104 | * 105 | * \param input Pointer to a null-terminated utf8 string containing 106 | * JSON data. 107 | * \param error_buffer Pointer to a buffer in which an error message will 108 | * be stored if \em yajl_tree_parse fails, or 109 | * \c NULL. The buffer will be initialized before 110 | * parsing, so its content will be destroyed even if 111 | * \em yajl_tree_parse succeeds. 112 | * \param error_buffer_size Size of the memory area pointed to by 113 | * \em error_buffer_size. If \em error_buffer_size is 114 | * \c NULL, this argument is ignored. 115 | * 116 | * \returns Pointer to the top-level value or \c NULL on error. The memory 117 | * pointed to must be freed using \em yajl_tree_free. In case of an error, a 118 | * null terminated message describing the error in more detail is stored in 119 | * \em error_buffer if it is not \c NULL. 120 | */ 121 | YAJL_API yajl_val yajl_tree_parse (const char *input, 122 | char *error_buffer, size_t error_buffer_size); 123 | 124 | /** 125 | * Free a parse tree returned by "yajl_tree_parse". 126 | * 127 | * \param v Pointer to a JSON value returned by "yajl_tree_parse". Passing NULL 128 | * is valid and results in a no-op. 129 | */ 130 | YAJL_API void yajl_tree_free (yajl_val v); 131 | 132 | /** 133 | * Access a nested value inside a tree. 134 | * 135 | * \param parent the node under which you'd like to extract values. 136 | * \param path A null terminated array of strings, each the name of an object key 137 | * \param type the yajl_type of the object you seek, or yajl_t_any if any will do. 138 | * 139 | * \returns a pointer to the found value, or NULL if we came up empty. 140 | * 141 | * Future Ideas: it'd be nice to move path to a string and implement support for 142 | * a teeny tiny micro language here, so you can extract array elements, do things 143 | * like .first and .last, even .length. Inspiration from JSONPath and css selectors? 144 | * No it wouldn't be fast, but that's not what this API is about. 145 | */ 146 | YAJL_API yajl_val yajl_tree_get(yajl_val parent, const char ** path, yajl_type type); 147 | 148 | /* Various convenience macros to check the type of a `yajl_val` */ 149 | #define YAJL_IS_STRING(v) (((v) != NULL) && ((v)->type == yajl_t_string)) 150 | #define YAJL_IS_NUMBER(v) (((v) != NULL) && ((v)->type == yajl_t_number)) 151 | #define YAJL_IS_INTEGER(v) (YAJL_IS_NUMBER(v) && ((v)->u.number.flags & YAJL_NUMBER_INT_VALID)) 152 | #define YAJL_IS_DOUBLE(v) (YAJL_IS_NUMBER(v) && ((v)->u.number.flags & YAJL_NUMBER_DOUBLE_VALID)) 153 | #define YAJL_IS_OBJECT(v) (((v) != NULL) && ((v)->type == yajl_t_object)) 154 | #define YAJL_IS_ARRAY(v) (((v) != NULL) && ((v)->type == yajl_t_array )) 155 | #define YAJL_IS_TRUE(v) (((v) != NULL) && ((v)->type == yajl_t_true )) 156 | #define YAJL_IS_FALSE(v) (((v) != NULL) && ((v)->type == yajl_t_false )) 157 | #define YAJL_IS_NULL(v) (((v) != NULL) && ((v)->type == yajl_t_null )) 158 | 159 | /** Given a yajl_val_string return a ptr to the bare string it contains, 160 | * or NULL if the value is not a string. */ 161 | #define YAJL_GET_STRING(v) (YAJL_IS_STRING(v) ? (v)->u.string : NULL) 162 | 163 | /** Get the string representation of a number. You should check type first, 164 | * perhaps using YAJL_IS_NUMBER */ 165 | #define YAJL_GET_NUMBER(v) ((v)->u.number.r) 166 | 167 | /** Get the double representation of a number. You should check type first, 168 | * perhaps using YAJL_IS_DOUBLE */ 169 | #define YAJL_GET_DOUBLE(v) ((v)->u.number.d) 170 | 171 | /** Get the 64bit (long long) integer representation of a number. You should 172 | * check type first, perhaps using YAJL_IS_INTEGER */ 173 | #define YAJL_GET_INTEGER(v) ((v)->u.number.i) 174 | 175 | /** Get a pointer to a yajl_val_object or NULL if the value is not an object. */ 176 | #define YAJL_GET_OBJECT(v) (YAJL_IS_OBJECT(v) ? &(v)->u.object : NULL) 177 | 178 | /** Get a pointer to a yajl_val_array or NULL if the value is not an object. */ 179 | #define YAJL_GET_ARRAY(v) (YAJL_IS_ARRAY(v) ? &(v)->u.array : NULL) 180 | 181 | #ifdef __cplusplus 182 | } 183 | #endif 184 | 185 | #endif /* YAJL_TREE_H */ 186 | -------------------------------------------------------------------------------- /YAJL/include/yajl/yajl_version.h: -------------------------------------------------------------------------------- 1 | #ifndef YAJL_VERSION_H_ 2 | #define YAJL_VERSION_H_ 3 | 4 | #include 5 | 6 | #define YAJL_MAJOR 2 7 | #define YAJL_MINOR 0 8 | #define YAJL_MICRO 3 9 | 10 | #define YAJL_VERSION ((YAJL_MAJOR * 10000) + (YAJL_MINOR * 100) + YAJL_MICRO) 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | extern int YAJL_API yajl_version(void); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif /* YAJL_VERSION_H_ */ 23 | 24 | --------------------------------------------------------------------------------