├── .gitignore ├── .gitmodules ├── Example └── JSONParserExample │ ├── JSONParserExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata │ ├── JSONParserExample │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift │ ├── JSONParserExampleTests │ ├── BasicTypes.json │ ├── Info.plist │ └── JSONParserExampleTests.swift │ ├── SwiftJSON │ ├── Info.plist │ ├── JSONPath.swift │ ├── SwiftJSONParser.h │ ├── SwiftJSONParser.swift │ └── SwiftRegex.swift │ └── SwiftJSONParser.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ └── xcshareddata │ └── xcschemes │ └── SwiftJSONParserTests.xcscheme ├── LICENSE ├── README.md ├── SwiftJSON ├── Info.plist ├── JSONPath.swift ├── SwiftJSONParser.h ├── SwiftJSONParser.swift └── SwiftRegex.swift ├── SwiftJSONParser.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── SwiftJSONParserTests.xcscheme └── SwiftJSONTests ├── BasicTypes.json ├── Benchmarks └── ParserBenchmarks.swift ├── ErrorHandingTests.swift ├── Info.plist ├── SwiftJSONParserTests.swift └── TweetsSearch.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | # Pods/ 27 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "SwiftJSONTests/Benchmarks/Other Parsers/SwiftyJSON"] 2 | path = SwiftJSONTests/Benchmarks/Other Parsers/SwiftyJSON 3 | url = git@github.com:SwiftyJSON/SwiftyJSON.git 4 | -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A9B9508C1A6376C700D3AAE3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B9508B1A6376C700D3AAE3 /* AppDelegate.swift */; }; 11 | A9B9508E1A6376C700D3AAE3 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B9508D1A6376C700D3AAE3 /* ViewController.swift */; }; 12 | A9B950911A6376C700D3AAE3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A9B9508F1A6376C700D3AAE3 /* Main.storyboard */; }; 13 | A9B950931A6376C700D3AAE3 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A9B950921A6376C700D3AAE3 /* Images.xcassets */; }; 14 | A9B950961A6376C700D3AAE3 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9B950941A6376C700D3AAE3 /* LaunchScreen.xib */; }; 15 | A9B950A21A6376C700D3AAE3 /* JSONParserExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B950A11A6376C700D3AAE3 /* JSONParserExampleTests.swift */; }; 16 | A9B950E01A637B4400D3AAE3 /* BasicTypes.json in Resources */ = {isa = PBXBuildFile; fileRef = A9B950DF1A637B4400D3AAE3 /* BasicTypes.json */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | A9B9509C1A6376C700D3AAE3 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = A9B9507E1A6376C700D3AAE3 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = A9B950851A6376C700D3AAE3; 25 | remoteInfo = JSONParserExample; 26 | }; 27 | A9B950D71A6377E300D3AAE3 /* PBXContainerItemProxy */ = { 28 | isa = PBXContainerItemProxy; 29 | containerPortal = A9B950CF1A6377E200D3AAE3 /* SwiftJSONParser.xcodeproj */; 30 | proxyType = 2; 31 | remoteGlobalIDString = A974F6CB19AE9A7700B9AB30; 32 | remoteInfo = SwiftJSONParser; 33 | }; 34 | A9B950D91A6377E300D3AAE3 /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = A9B950CF1A6377E200D3AAE3 /* SwiftJSONParser.xcodeproj */; 37 | proxyType = 2; 38 | remoteGlobalIDString = A974F6D619AE9A7800B9AB30; 39 | remoteInfo = SwiftJSONParserTests; 40 | }; 41 | A9B950DB1A6377FA00D3AAE3 /* PBXContainerItemProxy */ = { 42 | isa = PBXContainerItemProxy; 43 | containerPortal = A9B950CF1A6377E200D3AAE3 /* SwiftJSONParser.xcodeproj */; 44 | proxyType = 1; 45 | remoteGlobalIDString = A974F6CA19AE9A7700B9AB30; 46 | remoteInfo = SwiftJSONParser; 47 | }; 48 | /* End PBXContainerItemProxy section */ 49 | 50 | /* Begin PBXFileReference section */ 51 | A9B950861A6376C700D3AAE3 /* JSONParserExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JSONParserExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 52 | A9B9508A1A6376C700D3AAE3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 53 | A9B9508B1A6376C700D3AAE3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 54 | A9B9508D1A6376C700D3AAE3 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 55 | A9B950901A6376C700D3AAE3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 56 | A9B950921A6376C700D3AAE3 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 57 | A9B950951A6376C700D3AAE3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 58 | A9B9509B1A6376C700D3AAE3 /* JSONParserExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JSONParserExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | A9B950A01A6376C700D3AAE3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | A9B950A11A6376C700D3AAE3 /* JSONParserExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JSONParserExampleTests.swift; sourceTree = ""; }; 61 | A9B950CF1A6377E200D3AAE3 /* SwiftJSONParser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = SwiftJSONParser.xcodeproj; sourceTree = ""; }; 62 | A9B950DF1A637B4400D3AAE3 /* BasicTypes.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = BasicTypes.json; sourceTree = ""; }; 63 | /* End PBXFileReference section */ 64 | 65 | /* Begin PBXFrameworksBuildPhase section */ 66 | A9B950831A6376C700D3AAE3 /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | A9B950981A6376C700D3AAE3 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | A9B9507D1A6376C700D3AAE3 = { 84 | isa = PBXGroup; 85 | children = ( 86 | A9B950CF1A6377E200D3AAE3 /* SwiftJSONParser.xcodeproj */, 87 | A9B950881A6376C700D3AAE3 /* JSONParserExample */, 88 | A9B9509E1A6376C700D3AAE3 /* JSONParserExampleTests */, 89 | A9B950871A6376C700D3AAE3 /* Products */, 90 | ); 91 | sourceTree = ""; 92 | }; 93 | A9B950871A6376C700D3AAE3 /* Products */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | A9B950861A6376C700D3AAE3 /* JSONParserExample.app */, 97 | A9B9509B1A6376C700D3AAE3 /* JSONParserExampleTests.xctest */, 98 | ); 99 | name = Products; 100 | sourceTree = ""; 101 | }; 102 | A9B950881A6376C700D3AAE3 /* JSONParserExample */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | A9B9508B1A6376C700D3AAE3 /* AppDelegate.swift */, 106 | A9B9508D1A6376C700D3AAE3 /* ViewController.swift */, 107 | A9B9508F1A6376C700D3AAE3 /* Main.storyboard */, 108 | A9B950921A6376C700D3AAE3 /* Images.xcassets */, 109 | A9B950941A6376C700D3AAE3 /* LaunchScreen.xib */, 110 | A9B950891A6376C700D3AAE3 /* Supporting Files */, 111 | ); 112 | path = JSONParserExample; 113 | sourceTree = ""; 114 | }; 115 | A9B950891A6376C700D3AAE3 /* Supporting Files */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | A9B9508A1A6376C700D3AAE3 /* Info.plist */, 119 | ); 120 | name = "Supporting Files"; 121 | sourceTree = ""; 122 | }; 123 | A9B9509E1A6376C700D3AAE3 /* JSONParserExampleTests */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | A9B950DF1A637B4400D3AAE3 /* BasicTypes.json */, 127 | A9B950A11A6376C700D3AAE3 /* JSONParserExampleTests.swift */, 128 | A9B9509F1A6376C700D3AAE3 /* Supporting Files */, 129 | ); 130 | path = JSONParserExampleTests; 131 | sourceTree = ""; 132 | }; 133 | A9B9509F1A6376C700D3AAE3 /* Supporting Files */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | A9B950A01A6376C700D3AAE3 /* Info.plist */, 137 | ); 138 | name = "Supporting Files"; 139 | sourceTree = ""; 140 | }; 141 | A9B950D01A6377E200D3AAE3 /* Products */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | A9B950D81A6377E300D3AAE3 /* SwiftJSONParser.framework */, 145 | A9B950DA1A6377E300D3AAE3 /* SwiftJSONParserTests.xctest */, 146 | ); 147 | name = Products; 148 | sourceTree = ""; 149 | }; 150 | /* End PBXGroup section */ 151 | 152 | /* Begin PBXNativeTarget section */ 153 | A9B950851A6376C700D3AAE3 /* JSONParserExample */ = { 154 | isa = PBXNativeTarget; 155 | buildConfigurationList = A9B950A51A6376C700D3AAE3 /* Build configuration list for PBXNativeTarget "JSONParserExample" */; 156 | buildPhases = ( 157 | A9B950821A6376C700D3AAE3 /* Sources */, 158 | A9B950831A6376C700D3AAE3 /* Frameworks */, 159 | A9B950841A6376C700D3AAE3 /* Resources */, 160 | ); 161 | buildRules = ( 162 | ); 163 | dependencies = ( 164 | A9B950DC1A6377FA00D3AAE3 /* PBXTargetDependency */, 165 | ); 166 | name = JSONParserExample; 167 | productName = JSONParserExample; 168 | productReference = A9B950861A6376C700D3AAE3 /* JSONParserExample.app */; 169 | productType = "com.apple.product-type.application"; 170 | }; 171 | A9B9509A1A6376C700D3AAE3 /* JSONParserExampleTests */ = { 172 | isa = PBXNativeTarget; 173 | buildConfigurationList = A9B950A81A6376C700D3AAE3 /* Build configuration list for PBXNativeTarget "JSONParserExampleTests" */; 174 | buildPhases = ( 175 | A9B950971A6376C700D3AAE3 /* Sources */, 176 | A9B950981A6376C700D3AAE3 /* Frameworks */, 177 | A9B950991A6376C700D3AAE3 /* Resources */, 178 | ); 179 | buildRules = ( 180 | ); 181 | dependencies = ( 182 | A9B9509D1A6376C700D3AAE3 /* PBXTargetDependency */, 183 | ); 184 | name = JSONParserExampleTests; 185 | productName = JSONParserExampleTests; 186 | productReference = A9B9509B1A6376C700D3AAE3 /* JSONParserExampleTests.xctest */; 187 | productType = "com.apple.product-type.bundle.unit-test"; 188 | }; 189 | /* End PBXNativeTarget section */ 190 | 191 | /* Begin PBXProject section */ 192 | A9B9507E1A6376C700D3AAE3 /* Project object */ = { 193 | isa = PBXProject; 194 | attributes = { 195 | LastUpgradeCheck = 0610; 196 | ORGANIZATIONNAME = mrap; 197 | TargetAttributes = { 198 | A9B950851A6376C700D3AAE3 = { 199 | CreatedOnToolsVersion = 6.1.1; 200 | DevelopmentTeam = 8S26TG4YG6; 201 | }; 202 | A9B9509A1A6376C700D3AAE3 = { 203 | CreatedOnToolsVersion = 6.1.1; 204 | TestTargetID = A9B950851A6376C700D3AAE3; 205 | }; 206 | }; 207 | }; 208 | buildConfigurationList = A9B950811A6376C700D3AAE3 /* Build configuration list for PBXProject "JSONParserExample" */; 209 | compatibilityVersion = "Xcode 3.2"; 210 | developmentRegion = English; 211 | hasScannedForEncodings = 0; 212 | knownRegions = ( 213 | en, 214 | Base, 215 | ); 216 | mainGroup = A9B9507D1A6376C700D3AAE3; 217 | productRefGroup = A9B950871A6376C700D3AAE3 /* Products */; 218 | projectDirPath = ""; 219 | projectReferences = ( 220 | { 221 | ProductGroup = A9B950D01A6377E200D3AAE3 /* Products */; 222 | ProjectRef = A9B950CF1A6377E200D3AAE3 /* SwiftJSONParser.xcodeproj */; 223 | }, 224 | ); 225 | projectRoot = ""; 226 | targets = ( 227 | A9B950851A6376C700D3AAE3 /* JSONParserExample */, 228 | A9B9509A1A6376C700D3AAE3 /* JSONParserExampleTests */, 229 | ); 230 | }; 231 | /* End PBXProject section */ 232 | 233 | /* Begin PBXReferenceProxy section */ 234 | A9B950D81A6377E300D3AAE3 /* SwiftJSONParser.framework */ = { 235 | isa = PBXReferenceProxy; 236 | fileType = wrapper.framework; 237 | path = SwiftJSONParser.framework; 238 | remoteRef = A9B950D71A6377E300D3AAE3 /* PBXContainerItemProxy */; 239 | sourceTree = BUILT_PRODUCTS_DIR; 240 | }; 241 | A9B950DA1A6377E300D3AAE3 /* SwiftJSONParserTests.xctest */ = { 242 | isa = PBXReferenceProxy; 243 | fileType = wrapper.cfbundle; 244 | path = SwiftJSONParserTests.xctest; 245 | remoteRef = A9B950D91A6377E300D3AAE3 /* PBXContainerItemProxy */; 246 | sourceTree = BUILT_PRODUCTS_DIR; 247 | }; 248 | /* End PBXReferenceProxy section */ 249 | 250 | /* Begin PBXResourcesBuildPhase section */ 251 | A9B950841A6376C700D3AAE3 /* Resources */ = { 252 | isa = PBXResourcesBuildPhase; 253 | buildActionMask = 2147483647; 254 | files = ( 255 | A9B950911A6376C700D3AAE3 /* Main.storyboard in Resources */, 256 | A9B950961A6376C700D3AAE3 /* LaunchScreen.xib in Resources */, 257 | A9B950931A6376C700D3AAE3 /* Images.xcassets in Resources */, 258 | ); 259 | runOnlyForDeploymentPostprocessing = 0; 260 | }; 261 | A9B950991A6376C700D3AAE3 /* Resources */ = { 262 | isa = PBXResourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | A9B950E01A637B4400D3AAE3 /* BasicTypes.json in Resources */, 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | /* End PBXResourcesBuildPhase section */ 270 | 271 | /* Begin PBXSourcesBuildPhase section */ 272 | A9B950821A6376C700D3AAE3 /* Sources */ = { 273 | isa = PBXSourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | A9B9508E1A6376C700D3AAE3 /* ViewController.swift in Sources */, 277 | A9B9508C1A6376C700D3AAE3 /* AppDelegate.swift in Sources */, 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | }; 281 | A9B950971A6376C700D3AAE3 /* Sources */ = { 282 | isa = PBXSourcesBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | A9B950A21A6376C700D3AAE3 /* JSONParserExampleTests.swift in Sources */, 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | }; 289 | /* End PBXSourcesBuildPhase section */ 290 | 291 | /* Begin PBXTargetDependency section */ 292 | A9B9509D1A6376C700D3AAE3 /* PBXTargetDependency */ = { 293 | isa = PBXTargetDependency; 294 | target = A9B950851A6376C700D3AAE3 /* JSONParserExample */; 295 | targetProxy = A9B9509C1A6376C700D3AAE3 /* PBXContainerItemProxy */; 296 | }; 297 | A9B950DC1A6377FA00D3AAE3 /* PBXTargetDependency */ = { 298 | isa = PBXTargetDependency; 299 | name = SwiftJSONParser; 300 | targetProxy = A9B950DB1A6377FA00D3AAE3 /* PBXContainerItemProxy */; 301 | }; 302 | /* End PBXTargetDependency section */ 303 | 304 | /* Begin PBXVariantGroup section */ 305 | A9B9508F1A6376C700D3AAE3 /* Main.storyboard */ = { 306 | isa = PBXVariantGroup; 307 | children = ( 308 | A9B950901A6376C700D3AAE3 /* Base */, 309 | ); 310 | name = Main.storyboard; 311 | sourceTree = ""; 312 | }; 313 | A9B950941A6376C700D3AAE3 /* LaunchScreen.xib */ = { 314 | isa = PBXVariantGroup; 315 | children = ( 316 | A9B950951A6376C700D3AAE3 /* Base */, 317 | ); 318 | name = LaunchScreen.xib; 319 | sourceTree = ""; 320 | }; 321 | /* End PBXVariantGroup section */ 322 | 323 | /* Begin XCBuildConfiguration section */ 324 | A9B950A31A6376C700D3AAE3 /* Debug */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ALWAYS_SEARCH_USER_PATHS = NO; 328 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 329 | CLANG_CXX_LIBRARY = "libc++"; 330 | CLANG_ENABLE_MODULES = YES; 331 | CLANG_ENABLE_OBJC_ARC = YES; 332 | CLANG_WARN_BOOL_CONVERSION = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 335 | CLANG_WARN_EMPTY_BODY = YES; 336 | CLANG_WARN_ENUM_CONVERSION = YES; 337 | CLANG_WARN_INT_CONVERSION = YES; 338 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 339 | CLANG_WARN_UNREACHABLE_CODE = YES; 340 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 341 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 342 | COPY_PHASE_STRIP = NO; 343 | ENABLE_STRICT_OBJC_MSGSEND = YES; 344 | GCC_C_LANGUAGE_STANDARD = gnu99; 345 | GCC_DYNAMIC_NO_PIC = NO; 346 | GCC_OPTIMIZATION_LEVEL = 0; 347 | GCC_PREPROCESSOR_DEFINITIONS = ( 348 | "DEBUG=1", 349 | "$(inherited)", 350 | ); 351 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 352 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 353 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 354 | GCC_WARN_UNDECLARED_SELECTOR = YES; 355 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 356 | GCC_WARN_UNUSED_FUNCTION = YES; 357 | GCC_WARN_UNUSED_VARIABLE = YES; 358 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 359 | MTL_ENABLE_DEBUG_INFO = YES; 360 | ONLY_ACTIVE_ARCH = YES; 361 | SDKROOT = iphoneos; 362 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 363 | }; 364 | name = Debug; 365 | }; 366 | A9B950A41A6376C700D3AAE3 /* Release */ = { 367 | isa = XCBuildConfiguration; 368 | buildSettings = { 369 | ALWAYS_SEARCH_USER_PATHS = NO; 370 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 371 | CLANG_CXX_LIBRARY = "libc++"; 372 | CLANG_ENABLE_MODULES = YES; 373 | CLANG_ENABLE_OBJC_ARC = YES; 374 | CLANG_WARN_BOOL_CONVERSION = YES; 375 | CLANG_WARN_CONSTANT_CONVERSION = YES; 376 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 377 | CLANG_WARN_EMPTY_BODY = YES; 378 | CLANG_WARN_ENUM_CONVERSION = YES; 379 | CLANG_WARN_INT_CONVERSION = YES; 380 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 381 | CLANG_WARN_UNREACHABLE_CODE = YES; 382 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 383 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 384 | COPY_PHASE_STRIP = YES; 385 | ENABLE_NS_ASSERTIONS = NO; 386 | ENABLE_STRICT_OBJC_MSGSEND = YES; 387 | GCC_C_LANGUAGE_STANDARD = gnu99; 388 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 389 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 390 | GCC_WARN_UNDECLARED_SELECTOR = YES; 391 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 392 | GCC_WARN_UNUSED_FUNCTION = YES; 393 | GCC_WARN_UNUSED_VARIABLE = YES; 394 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 395 | MTL_ENABLE_DEBUG_INFO = NO; 396 | SDKROOT = iphoneos; 397 | VALIDATE_PRODUCT = YES; 398 | }; 399 | name = Release; 400 | }; 401 | A9B950A61A6376C700D3AAE3 /* Debug */ = { 402 | isa = XCBuildConfiguration; 403 | buildSettings = { 404 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 405 | INFOPLIST_FILE = JSONParserExample/Info.plist; 406 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 407 | PRODUCT_NAME = "$(TARGET_NAME)"; 408 | }; 409 | name = Debug; 410 | }; 411 | A9B950A71A6376C700D3AAE3 /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 415 | INFOPLIST_FILE = JSONParserExample/Info.plist; 416 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 417 | PRODUCT_NAME = "$(TARGET_NAME)"; 418 | }; 419 | name = Release; 420 | }; 421 | A9B950A91A6376C700D3AAE3 /* Debug */ = { 422 | isa = XCBuildConfiguration; 423 | buildSettings = { 424 | BUNDLE_LOADER = "$(TEST_HOST)"; 425 | FRAMEWORK_SEARCH_PATHS = ( 426 | "$(SDKROOT)/Developer/Library/Frameworks", 427 | "$(inherited)", 428 | ); 429 | GCC_PREPROCESSOR_DEFINITIONS = ( 430 | "DEBUG=1", 431 | "$(inherited)", 432 | ); 433 | INFOPLIST_FILE = JSONParserExampleTests/Info.plist; 434 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 435 | PRODUCT_NAME = "$(TARGET_NAME)"; 436 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JSONParserExample.app/JSONParserExample"; 437 | }; 438 | name = Debug; 439 | }; 440 | A9B950AA1A6376C700D3AAE3 /* Release */ = { 441 | isa = XCBuildConfiguration; 442 | buildSettings = { 443 | BUNDLE_LOADER = "$(TEST_HOST)"; 444 | FRAMEWORK_SEARCH_PATHS = ( 445 | "$(SDKROOT)/Developer/Library/Frameworks", 446 | "$(inherited)", 447 | ); 448 | INFOPLIST_FILE = JSONParserExampleTests/Info.plist; 449 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/JSONParserExample.app/JSONParserExample"; 452 | }; 453 | name = Release; 454 | }; 455 | /* End XCBuildConfiguration section */ 456 | 457 | /* Begin XCConfigurationList section */ 458 | A9B950811A6376C700D3AAE3 /* Build configuration list for PBXProject "JSONParserExample" */ = { 459 | isa = XCConfigurationList; 460 | buildConfigurations = ( 461 | A9B950A31A6376C700D3AAE3 /* Debug */, 462 | A9B950A41A6376C700D3AAE3 /* Release */, 463 | ); 464 | defaultConfigurationIsVisible = 0; 465 | defaultConfigurationName = Release; 466 | }; 467 | A9B950A51A6376C700D3AAE3 /* Build configuration list for PBXNativeTarget "JSONParserExample" */ = { 468 | isa = XCConfigurationList; 469 | buildConfigurations = ( 470 | A9B950A61A6376C700D3AAE3 /* Debug */, 471 | A9B950A71A6376C700D3AAE3 /* Release */, 472 | ); 473 | defaultConfigurationIsVisible = 0; 474 | }; 475 | A9B950A81A6376C700D3AAE3 /* Build configuration list for PBXNativeTarget "JSONParserExampleTests" */ = { 476 | isa = XCConfigurationList; 477 | buildConfigurations = ( 478 | A9B950A91A6376C700D3AAE3 /* Debug */, 479 | A9B950AA1A6376C700D3AAE3 /* Release */, 480 | ); 481 | defaultConfigurationIsVisible = 0; 482 | }; 483 | /* End XCConfigurationList section */ 484 | }; 485 | rootObject = A9B9507E1A6376C700D3AAE3 /* Project object */; 486 | } 487 | -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // JSONParserExample 4 | // 5 | // Created by mrap on 1/11/15. 6 | // Copyright (c) 2015 mrap. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | mrap.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // JSONParserExample 4 | // 5 | // Created by mrap on 1/11/15. 6 | // Copyright (c) 2015 mrap. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | } 17 | 18 | override func didReceiveMemoryWarning() { 19 | super.didReceiveMemoryWarning() 20 | // Dispose of any resources that can be recreated. 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExampleTests/BasicTypes.json: -------------------------------------------------------------------------------- 1 | { 2 | "keyForString": "string", 3 | "keyForInt": 42, 4 | "keyForDouble": 98.6, 5 | "keyForArray": ["string", 42, 98.6], 6 | "nested": { 7 | "keyForString": "string", 8 | "keyForInt": 42, 9 | "keyForDouble": 98.6, 10 | "keyForArray": ["string", 42, 98.6] 11 | } 12 | } -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | mrap.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/JSONParserExample/JSONParserExampleTests/JSONParserExampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JSONParserExampleTests.swift 3 | // JSONParserExampleTests 4 | // 5 | // Created by mrap on 1/11/15. 6 | // Copyright (c) 2015 mrap. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | import SwiftJSONParser 12 | 13 | class JSONParserExampleTests: XCTestCase { 14 | 15 | var data: NSData? 16 | var parser = JSONParser(nil) 17 | 18 | override func setUp() { 19 | super.setUp() 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | if let path = NSBundle(forClass: JSONParserExampleTests.self).pathForResource("BasicTypes", ofType: "json") { 23 | var error: NSError? 24 | self.data = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: &error) 25 | self.parser = JSONParser(data) 26 | } 27 | } 28 | 29 | override func tearDown() { 30 | // Put teardown code here. This method is called after the invocation of each test method in the class. 31 | super.tearDown() 32 | } 33 | 34 | func testParseWithParser() { 35 | self.measureBlock() { 36 | for i in 0...10000 { 37 | if let val = self.parser.getString("keyForString") { 38 | } else { 39 | XCTFail("Should have string value") 40 | } 41 | } 42 | } 43 | } 44 | 45 | func testParse() { 46 | self.measureBlock() { 47 | for i in 0...10000 { 48 | var parseError: NSError? 49 | let parsedObject: AnyObject? = NSJSONSerialization.JSONObjectWithData(self.data!, 50 | options: NSJSONReadingOptions.AllowFragments, 51 | error:&parseError) 52 | 53 | if let top = parsedObject as? NSDictionary { 54 | if let val = top["keyForString"] as? String { 55 | } else { 56 | XCTFail("Should have string value") 57 | } 58 | } 59 | } 60 | } 61 | } 62 | 63 | func testParseArray() { 64 | self.measureBlock() { 65 | for i in 0...10000 { 66 | var parseError: NSError? 67 | let parsedObject: AnyObject? = NSJSONSerialization.JSONObjectWithData(self.data!, 68 | options: NSJSONReadingOptions.AllowFragments, 69 | error:&parseError) 70 | 71 | if let top = parsedObject as? NSDictionary { 72 | if let arr = top["keyForArray"] as? [AnyObject] { 73 | XCTAssertEqual(arr[0] as String, "string", "Should have string value") 74 | } else { 75 | XCTFail("Should have string value") 76 | } 77 | } 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Example/JSONParserExample/SwiftJSON/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | mrap.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/JSONParserExample/SwiftJSON/JSONPath.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JSONPath.swift 3 | // SwiftJSONParser 4 | // 5 | // Created by mrap on 8/27/14. 6 | // Copyright (c) 2014 Mike Rapadas. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class JSONPath { 12 | let path: String? 13 | var pathComponents = Array() 14 | 15 | init(_ path: String?) { 16 | if let nsPath = path as NSString? { 17 | self.path = path 18 | pathComponents = nsPath.componentsSeparatedByString(".") as Array 19 | } 20 | } 21 | 22 | func popNext() -> String? { 23 | if pathComponents.isEmpty { return nil } 24 | return pathComponents.removeAtIndex(0) 25 | } 26 | 27 | class func getArrayKeyAndIndex(optionalKey: String?) -> (String?, Int?)? { 28 | if let key = optionalKey as String? { 29 | var arrayKey: String? 30 | var arrayIndex: Int? 31 | var itr = 0 32 | 33 | // Match the key of the array and the index 34 | for match in key =~ "\\w+(?=\\[)|(?<=\\w\\[)(\\d+)(?=\\])" { 35 | if (itr == 0) { 36 | arrayKey = match 37 | } else { 38 | arrayIndex = match.toInt() 39 | } 40 | ++itr 41 | } 42 | return (arrayKey, arrayIndex) 43 | } 44 | 45 | return nil 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Example/JSONParserExample/SwiftJSON/SwiftJSONParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftJSONParser.h 3 | // SwiftJSONParser 4 | // 5 | // Created by mrap on 8/27/14. 6 | // Copyright (c) 2014 Mike Rapadas. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for SwiftJSONParser. 12 | FOUNDATION_EXPORT double SwiftJSONParserVersionNumber; 13 | 14 | //! Project version string for SwiftJSONParser. 15 | FOUNDATION_EXPORT const unsigned char SwiftJSONParserVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Example/JSONParserExample/SwiftJSON/SwiftJSONParser.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftJSONParser.swift 3 | // SwiftJSONParser 4 | // 5 | // Created by mrap on 8/27/14. 6 | // Copyright (c) 2014 Mike Rapadas. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | private typealias _JSON = AnyObject 12 | private typealias _JSONDictionary = Dictionary 13 | private typealias _JSONArray = Array<_JSON> 14 | 15 | private func jsonDictionary(fromData: NSData?, error: NSErrorPointer) -> _JSONDictionary? { 16 | if let data = fromData { 17 | var jsonErrorOptional: NSError? 18 | if let dict: AnyObject = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(0), error: &jsonErrorOptional) { 19 | return dict as? _JSONDictionary 20 | } 21 | } 22 | 23 | return nil 24 | } 25 | 26 | public class JSONParser { 27 | private let _json: _JSONDictionary? 28 | public let error: NSError? 29 | 30 | init() { 31 | } 32 | 33 | public init(_ data: NSData?) { 34 | if data != nil { 35 | self._json = jsonDictionary(data, &self.error) 36 | } else { 37 | self.error = NSError(domain: "com.mrap.SwiftJSONParser", code: 100, userInfo: [NSLocalizedDescriptionKey: "Parser did not have any data to parse"]) 38 | } 39 | } 40 | 41 | public func get(path: String?) -> AnyObject? { 42 | return getFinalValue(_json, withPath: JSONPath(path) ) 43 | } 44 | 45 | public func getString(path: String?) -> String? { 46 | return self.get(path) as? String 47 | } 48 | 49 | public func getInt(path: String?) -> Int? { 50 | return self.get(path) as? Int 51 | } 52 | 53 | public func getDouble(path: String?) -> Double? { 54 | return self.get(path) as? Double 55 | } 56 | 57 | public func getArray(path: String?) -> Array? { 58 | return self.get(path) as? Array 59 | } 60 | 61 | private func getFinalValue(json: _JSON?, withPath path: JSONPath) -> _JSON? { 62 | if json == nil { return nil } 63 | if let nextKey = path.popNext() { 64 | 65 | // Handle _JSONArray type here 66 | // Get the value from the array and call recursively on the child 67 | if let (arrayKey, arrayIndex) = JSONPath.getArrayKeyAndIndex(nextKey) { 68 | if arrayKey != nil && arrayIndex != nil { 69 | if let array = json![arrayKey!] as? _JSONArray { 70 | return getFinalValue(array[arrayIndex!] as _JSON, withPath: path) 71 | } 72 | } 73 | } 74 | 75 | if let value: AnyObject = json![nextKey] { 76 | return getFinalValue(value, withPath: path) 77 | } else { 78 | return nil 79 | } 80 | } 81 | 82 | return json 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /Example/JSONParserExample/SwiftJSON/SwiftRegex.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftRegex.swift 3 | // SwiftRegex 4 | // 5 | // Created by Gregory Todd Williams on 6/7/14. 6 | // Copyright (c) 2014 Gregory Todd Williams. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | infix operator =~ {} 12 | 13 | func =~ (value : String, pattern : String) -> RegexMatchResult { 14 | var err : NSError? 15 | let nsstr = value as NSString // we use this to access the NSString methods like .length and .substringWithRange(NSRange) 16 | let options = NSRegularExpressionOptions(0) 17 | let re = NSRegularExpression(pattern: pattern, options: options, error: &err) 18 | if let e = err { 19 | return RegexMatchResult(items: []) 20 | } 21 | let all = NSRange(location: 0, length: nsstr.length) 22 | let moptions = NSMatchingOptions(0) 23 | var matches : Array = [] 24 | re!.enumerateMatchesInString(value, options: moptions, range: all) { 25 | (result : NSTextCheckingResult!, flags : NSMatchingFlags, ptr : UnsafeMutablePointer) in 26 | let string = nsstr.substringWithRange(result.range) 27 | matches.append(string) 28 | } 29 | return RegexMatchResult(items: matches) 30 | } 31 | 32 | struct RegexMatchCaptureGenerator : GeneratorType { 33 | mutating func next() -> String? { 34 | if items.isEmpty { return nil } 35 | let ret = items[0] 36 | items = items[1.. 40 | } 41 | 42 | struct RegexMatchResult : SequenceType, BooleanType { 43 | var items: Array 44 | func generate() -> RegexMatchCaptureGenerator { 45 | return RegexMatchCaptureGenerator(items: items[0.. 0 49 | } 50 | subscript (i: Int) -> String { 51 | return items[i] 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/JSONParserExample/SwiftJSONParser.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A954079719AEDDCC0076E292 /* SwiftJSONParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A974F6EE19AED6C000B9AB30 /* SwiftJSONParser.swift */; }; 11 | A954079919AEF2620076E292 /* JSONPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = A954079819AEF2620076E292 /* JSONPath.swift */; }; 12 | A954079A19AEF2620076E292 /* JSONPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = A954079819AEF2620076E292 /* JSONPath.swift */; }; 13 | A95407A719AFBCA90076E292 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95407A619AFBCA90076E292 /* SwiftRegex.swift */; }; 14 | A95407A819AFBCA90076E292 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95407A619AFBCA90076E292 /* SwiftRegex.swift */; }; 15 | A974F6D119AE9A7700B9AB30 /* SwiftJSONParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A974F6D019AE9A7700B9AB30 /* SwiftJSONParser.h */; settings = {ATTRIBUTES = (Public, ); }; }; 16 | A974F6DB19AE9A7800B9AB30 /* SwiftJSONParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A974F6DA19AE9A7800B9AB30 /* SwiftJSONParserTests.swift */; }; 17 | A974F6ED19AEC7F700B9AB30 /* BasicTypes.json in Resources */ = {isa = PBXBuildFile; fileRef = A974F6EB19AEC6C600B9AB30 /* BasicTypes.json */; }; 18 | A974F6EF19AED6C000B9AB30 /* SwiftJSONParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A974F6EE19AED6C000B9AB30 /* SwiftJSONParser.swift */; }; 19 | A9D3AAC51A6358940071D8A9 /* Other Parsers in Resources */ = {isa = PBXBuildFile; fileRef = A9D3AAC41A6358940071D8A9 /* Other Parsers */; }; 20 | A9D3AACA1A6358F80071D8A9 /* ParserBenchmarks.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D3AAC91A6358F80071D8A9 /* ParserBenchmarks.swift */; }; 21 | A9D3AAD01A6365500071D8A9 /* SwiftyJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D3AACE1A6361B70071D8A9 /* SwiftyJSON.swift */; }; 22 | A9D3AAD21A6368610071D8A9 /* TweetsSearch.json in Resources */ = {isa = PBXBuildFile; fileRef = A9D3AAD11A6368610071D8A9 /* TweetsSearch.json */; }; 23 | A9F8A08119B598B1000D9907 /* ErrorHandingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F8A08019B598B1000D9907 /* ErrorHandingTests.swift */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | A954079819AEF2620076E292 /* JSONPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONPath.swift; sourceTree = ""; }; 28 | A95407A619AFBCA90076E292 /* SwiftRegex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftRegex.swift; sourceTree = ""; }; 29 | A974F6CB19AE9A7700B9AB30 /* SwiftJSONParser.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftJSONParser.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | A974F6CF19AE9A7700B9AB30 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | A974F6D019AE9A7700B9AB30 /* SwiftJSONParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftJSONParser.h; sourceTree = ""; }; 32 | A974F6D619AE9A7800B9AB30 /* SwiftJSONParserTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftJSONParserTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | A974F6D919AE9A7800B9AB30 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | A974F6DA19AE9A7800B9AB30 /* SwiftJSONParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftJSONParserTests.swift; sourceTree = ""; }; 35 | A974F6EB19AEC6C600B9AB30 /* BasicTypes.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = BasicTypes.json; sourceTree = ""; }; 36 | A974F6EE19AED6C000B9AB30 /* SwiftJSONParser.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; path = SwiftJSONParser.swift; sourceTree = ""; }; 37 | A9D3AAC41A6358940071D8A9 /* Other Parsers */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Other Parsers"; path = "Benchmarks/Other Parsers"; sourceTree = ""; }; 38 | A9D3AAC91A6358F80071D8A9 /* ParserBenchmarks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ParserBenchmarks.swift; path = Benchmarks/ParserBenchmarks.swift; sourceTree = ""; }; 39 | A9D3AACE1A6361B70071D8A9 /* SwiftyJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SwiftyJSON.swift; path = "SwiftJSONTests/Benchmarks/Other Parsers/SwiftyJSON/Source/SwiftyJSON.swift"; sourceTree = ""; }; 40 | A9D3AAD11A6368610071D8A9 /* TweetsSearch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TweetsSearch.json; sourceTree = ""; }; 41 | A9F8A08019B598B1000D9907 /* ErrorHandingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorHandingTests.swift; sourceTree = ""; }; 42 | /* End PBXFileReference section */ 43 | 44 | /* Begin PBXFrameworksBuildPhase section */ 45 | A974F6C719AE9A7700B9AB30 /* Frameworks */ = { 46 | isa = PBXFrameworksBuildPhase; 47 | buildActionMask = 2147483647; 48 | files = ( 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | A974F6D319AE9A7800B9AB30 /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | /* End PBXFrameworksBuildPhase section */ 60 | 61 | /* Begin PBXGroup section */ 62 | A974F6C119AE9A7700B9AB30 = { 63 | isa = PBXGroup; 64 | children = ( 65 | A9D3AACE1A6361B70071D8A9 /* SwiftyJSON.swift */, 66 | A974F6CD19AE9A7700B9AB30 /* SwiftJSONParser */, 67 | A974F6D719AE9A7800B9AB30 /* SwiftJSONParserTests */, 68 | A974F6CC19AE9A7700B9AB30 /* Products */, 69 | ); 70 | sourceTree = ""; 71 | }; 72 | A974F6CC19AE9A7700B9AB30 /* Products */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | A974F6CB19AE9A7700B9AB30 /* SwiftJSONParser.framework */, 76 | A974F6D619AE9A7800B9AB30 /* SwiftJSONParserTests.xctest */, 77 | ); 78 | name = Products; 79 | sourceTree = ""; 80 | }; 81 | A974F6CD19AE9A7700B9AB30 /* SwiftJSONParser */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | A974F6D019AE9A7700B9AB30 /* SwiftJSONParser.h */, 85 | A974F6EE19AED6C000B9AB30 /* SwiftJSONParser.swift */, 86 | A954079819AEF2620076E292 /* JSONPath.swift */, 87 | A95407A619AFBCA90076E292 /* SwiftRegex.swift */, 88 | A974F6CE19AE9A7700B9AB30 /* Supporting Files */, 89 | ); 90 | name = SwiftJSONParser; 91 | path = SwiftJSON; 92 | sourceTree = ""; 93 | }; 94 | A974F6CE19AE9A7700B9AB30 /* Supporting Files */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | A974F6CF19AE9A7700B9AB30 /* Info.plist */, 98 | ); 99 | name = "Supporting Files"; 100 | sourceTree = ""; 101 | }; 102 | A974F6D719AE9A7800B9AB30 /* SwiftJSONParserTests */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | A974F6DA19AE9A7800B9AB30 /* SwiftJSONParserTests.swift */, 106 | A9F8A08019B598B1000D9907 /* ErrorHandingTests.swift */, 107 | A974F6EA19AEC6B500B9AB30 /* Fixtures */, 108 | A974F6D819AE9A7800B9AB30 /* Supporting Files */, 109 | A9D3AAC71A6358C30071D8A9 /* Benchmarks */, 110 | ); 111 | name = SwiftJSONParserTests; 112 | path = SwiftJSONTests; 113 | sourceTree = ""; 114 | }; 115 | A974F6D819AE9A7800B9AB30 /* Supporting Files */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | A974F6D919AE9A7800B9AB30 /* Info.plist */, 119 | ); 120 | name = "Supporting Files"; 121 | sourceTree = ""; 122 | }; 123 | A974F6EA19AEC6B500B9AB30 /* Fixtures */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | A974F6EB19AEC6C600B9AB30 /* BasicTypes.json */, 127 | A9D3AAD11A6368610071D8A9 /* TweetsSearch.json */, 128 | ); 129 | name = Fixtures; 130 | sourceTree = ""; 131 | }; 132 | A9D3AAC71A6358C30071D8A9 /* Benchmarks */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | A9D3AAC91A6358F80071D8A9 /* ParserBenchmarks.swift */, 136 | A9D3AAC41A6358940071D8A9 /* Other Parsers */, 137 | ); 138 | name = Benchmarks; 139 | sourceTree = ""; 140 | }; 141 | /* End PBXGroup section */ 142 | 143 | /* Begin PBXHeadersBuildPhase section */ 144 | A974F6C819AE9A7700B9AB30 /* Headers */ = { 145 | isa = PBXHeadersBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | A974F6D119AE9A7700B9AB30 /* SwiftJSONParser.h in Headers */, 149 | ); 150 | runOnlyForDeploymentPostprocessing = 0; 151 | }; 152 | /* End PBXHeadersBuildPhase section */ 153 | 154 | /* Begin PBXNativeTarget section */ 155 | A974F6CA19AE9A7700B9AB30 /* SwiftJSONParser */ = { 156 | isa = PBXNativeTarget; 157 | buildConfigurationList = A974F6DE19AE9A7800B9AB30 /* Build configuration list for PBXNativeTarget "SwiftJSONParser" */; 158 | buildPhases = ( 159 | A974F6C619AE9A7700B9AB30 /* Sources */, 160 | A974F6C719AE9A7700B9AB30 /* Frameworks */, 161 | A974F6C819AE9A7700B9AB30 /* Headers */, 162 | A974F6C919AE9A7700B9AB30 /* Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | ); 168 | name = SwiftJSONParser; 169 | productName = SwiftJSON; 170 | productReference = A974F6CB19AE9A7700B9AB30 /* SwiftJSONParser.framework */; 171 | productType = "com.apple.product-type.framework"; 172 | }; 173 | A974F6D519AE9A7800B9AB30 /* SwiftJSONParserTests */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = A974F6E119AE9A7800B9AB30 /* Build configuration list for PBXNativeTarget "SwiftJSONParserTests" */; 176 | buildPhases = ( 177 | A974F6D219AE9A7800B9AB30 /* Sources */, 178 | A974F6D319AE9A7800B9AB30 /* Frameworks */, 179 | A974F6D419AE9A7800B9AB30 /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | ); 185 | name = SwiftJSONParserTests; 186 | productName = SwiftJSONTests; 187 | productReference = A974F6D619AE9A7800B9AB30 /* SwiftJSONParserTests.xctest */; 188 | productType = "com.apple.product-type.bundle.unit-test"; 189 | }; 190 | /* End PBXNativeTarget section */ 191 | 192 | /* Begin PBXProject section */ 193 | A974F6C219AE9A7700B9AB30 /* Project object */ = { 194 | isa = PBXProject; 195 | attributes = { 196 | LastUpgradeCheck = 0600; 197 | ORGANIZATIONNAME = "Mike Rapadas"; 198 | TargetAttributes = { 199 | A974F6CA19AE9A7700B9AB30 = { 200 | CreatedOnToolsVersion = 6.0; 201 | }; 202 | A974F6D519AE9A7800B9AB30 = { 203 | CreatedOnToolsVersion = 6.0; 204 | }; 205 | }; 206 | }; 207 | buildConfigurationList = A974F6C519AE9A7700B9AB30 /* Build configuration list for PBXProject "SwiftJSONParser" */; 208 | compatibilityVersion = "Xcode 3.2"; 209 | developmentRegion = English; 210 | hasScannedForEncodings = 0; 211 | knownRegions = ( 212 | en, 213 | ); 214 | mainGroup = A974F6C119AE9A7700B9AB30; 215 | productRefGroup = A974F6CC19AE9A7700B9AB30 /* Products */; 216 | projectDirPath = ""; 217 | projectRoot = ""; 218 | targets = ( 219 | A974F6CA19AE9A7700B9AB30 /* SwiftJSONParser */, 220 | A974F6D519AE9A7800B9AB30 /* SwiftJSONParserTests */, 221 | ); 222 | }; 223 | /* End PBXProject section */ 224 | 225 | /* Begin PBXResourcesBuildPhase section */ 226 | A974F6C919AE9A7700B9AB30 /* Resources */ = { 227 | isa = PBXResourcesBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | A974F6D419AE9A7800B9AB30 /* Resources */ = { 234 | isa = PBXResourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | A974F6ED19AEC7F700B9AB30 /* BasicTypes.json in Resources */, 238 | A9D3AAD21A6368610071D8A9 /* TweetsSearch.json in Resources */, 239 | A9D3AAC51A6358940071D8A9 /* Other Parsers in Resources */, 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | }; 243 | /* End PBXResourcesBuildPhase section */ 244 | 245 | /* Begin PBXSourcesBuildPhase section */ 246 | A974F6C619AE9A7700B9AB30 /* Sources */ = { 247 | isa = PBXSourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | A954079919AEF2620076E292 /* JSONPath.swift in Sources */, 251 | A974F6EF19AED6C000B9AB30 /* SwiftJSONParser.swift in Sources */, 252 | A95407A719AFBCA90076E292 /* SwiftRegex.swift in Sources */, 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | A974F6D219AE9A7800B9AB30 /* Sources */ = { 257 | isa = PBXSourcesBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | A9D3AACA1A6358F80071D8A9 /* ParserBenchmarks.swift in Sources */, 261 | A954079719AEDDCC0076E292 /* SwiftJSONParser.swift in Sources */, 262 | A974F6DB19AE9A7800B9AB30 /* SwiftJSONParserTests.swift in Sources */, 263 | A954079A19AEF2620076E292 /* JSONPath.swift in Sources */, 264 | A9F8A08119B598B1000D9907 /* ErrorHandingTests.swift in Sources */, 265 | A95407A819AFBCA90076E292 /* SwiftRegex.swift in Sources */, 266 | A9D3AAD01A6365500071D8A9 /* SwiftyJSON.swift in Sources */, 267 | ); 268 | runOnlyForDeploymentPostprocessing = 0; 269 | }; 270 | /* End PBXSourcesBuildPhase section */ 271 | 272 | /* Begin XCBuildConfiguration section */ 273 | A974F6DC19AE9A7800B9AB30 /* Debug */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | ALWAYS_SEARCH_USER_PATHS = NO; 277 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 278 | CLANG_CXX_LIBRARY = "libc++"; 279 | CLANG_ENABLE_MODULES = YES; 280 | CLANG_ENABLE_OBJC_ARC = YES; 281 | CLANG_WARN_BOOL_CONVERSION = YES; 282 | CLANG_WARN_CONSTANT_CONVERSION = YES; 283 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 284 | CLANG_WARN_EMPTY_BODY = YES; 285 | CLANG_WARN_ENUM_CONVERSION = YES; 286 | CLANG_WARN_INT_CONVERSION = YES; 287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 288 | CLANG_WARN_UNREACHABLE_CODE = YES; 289 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 290 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 291 | COPY_PHASE_STRIP = NO; 292 | CURRENT_PROJECT_VERSION = 1; 293 | ENABLE_STRICT_OBJC_MSGSEND = YES; 294 | GCC_C_LANGUAGE_STANDARD = gnu99; 295 | GCC_DYNAMIC_NO_PIC = NO; 296 | GCC_OPTIMIZATION_LEVEL = 0; 297 | GCC_PREPROCESSOR_DEFINITIONS = ( 298 | "DEBUG=1", 299 | "$(inherited)", 300 | ); 301 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 302 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 303 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 304 | GCC_WARN_UNDECLARED_SELECTOR = YES; 305 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 306 | GCC_WARN_UNUSED_FUNCTION = YES; 307 | GCC_WARN_UNUSED_VARIABLE = YES; 308 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 309 | MTL_ENABLE_DEBUG_INFO = YES; 310 | ONLY_ACTIVE_ARCH = YES; 311 | SDKROOT = iphoneos; 312 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 313 | TARGETED_DEVICE_FAMILY = "1,2"; 314 | VERSIONING_SYSTEM = "apple-generic"; 315 | VERSION_INFO_PREFIX = ""; 316 | }; 317 | name = Debug; 318 | }; 319 | A974F6DD19AE9A7800B9AB30 /* Release */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ALWAYS_SEARCH_USER_PATHS = NO; 323 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 324 | CLANG_CXX_LIBRARY = "libc++"; 325 | CLANG_ENABLE_MODULES = YES; 326 | CLANG_ENABLE_OBJC_ARC = YES; 327 | CLANG_WARN_BOOL_CONVERSION = YES; 328 | CLANG_WARN_CONSTANT_CONVERSION = YES; 329 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 330 | CLANG_WARN_EMPTY_BODY = YES; 331 | CLANG_WARN_ENUM_CONVERSION = YES; 332 | CLANG_WARN_INT_CONVERSION = YES; 333 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 334 | CLANG_WARN_UNREACHABLE_CODE = YES; 335 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 336 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 337 | COPY_PHASE_STRIP = YES; 338 | CURRENT_PROJECT_VERSION = 1; 339 | ENABLE_NS_ASSERTIONS = NO; 340 | ENABLE_STRICT_OBJC_MSGSEND = YES; 341 | GCC_C_LANGUAGE_STANDARD = gnu99; 342 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 343 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 344 | GCC_WARN_UNDECLARED_SELECTOR = YES; 345 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 346 | GCC_WARN_UNUSED_FUNCTION = YES; 347 | GCC_WARN_UNUSED_VARIABLE = YES; 348 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 349 | MTL_ENABLE_DEBUG_INFO = NO; 350 | SDKROOT = iphoneos; 351 | TARGETED_DEVICE_FAMILY = "1,2"; 352 | VALIDATE_PRODUCT = YES; 353 | VERSIONING_SYSTEM = "apple-generic"; 354 | VERSION_INFO_PREFIX = ""; 355 | }; 356 | name = Release; 357 | }; 358 | A974F6DF19AE9A7800B9AB30 /* Debug */ = { 359 | isa = XCBuildConfiguration; 360 | buildSettings = { 361 | CLANG_ENABLE_MODULES = YES; 362 | DEFINES_MODULE = YES; 363 | DYLIB_COMPATIBILITY_VERSION = 1; 364 | DYLIB_CURRENT_VERSION = 1; 365 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 366 | INFOPLIST_FILE = SwiftJSON/Info.plist; 367 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 368 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 369 | PRODUCT_NAME = SwiftJSONParser; 370 | SKIP_INSTALL = YES; 371 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 372 | }; 373 | name = Debug; 374 | }; 375 | A974F6E019AE9A7800B9AB30 /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | CLANG_ENABLE_MODULES = YES; 379 | DEFINES_MODULE = YES; 380 | DYLIB_COMPATIBILITY_VERSION = 1; 381 | DYLIB_CURRENT_VERSION = 1; 382 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 383 | INFOPLIST_FILE = SwiftJSON/Info.plist; 384 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 385 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 386 | PRODUCT_NAME = SwiftJSONParser; 387 | SKIP_INSTALL = YES; 388 | }; 389 | name = Release; 390 | }; 391 | A974F6E219AE9A7800B9AB30 /* Debug */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | FRAMEWORK_SEARCH_PATHS = ( 395 | "$(SDKROOT)/Developer/Library/Frameworks", 396 | "$(inherited)", 397 | "$(PROJECT_DIR)/SwiftJSONTests/Benchmarks/Other", 398 | "Parsers/SwiftyJSON/build/Debug-iphoneos", 399 | ); 400 | GCC_PREPROCESSOR_DEFINITIONS = ( 401 | "DEBUG=1", 402 | "$(inherited)", 403 | ); 404 | INFOPLIST_FILE = SwiftJSONTests/Info.plist; 405 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 406 | PRODUCT_NAME = SwiftJSONParserTests; 407 | SWIFT_INCLUDE_PATHS = ""; 408 | }; 409 | name = Debug; 410 | }; 411 | A974F6E319AE9A7800B9AB30 /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | FRAMEWORK_SEARCH_PATHS = ( 415 | "$(SDKROOT)/Developer/Library/Frameworks", 416 | "$(inherited)", 417 | "$(PROJECT_DIR)/SwiftJSONTests/Benchmarks/Other", 418 | "Parsers/SwiftyJSON/build/Debug-iphoneos", 419 | ); 420 | INFOPLIST_FILE = SwiftJSONTests/Info.plist; 421 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 422 | PRODUCT_NAME = SwiftJSONParserTests; 423 | SWIFT_INCLUDE_PATHS = ""; 424 | }; 425 | name = Release; 426 | }; 427 | /* End XCBuildConfiguration section */ 428 | 429 | /* Begin XCConfigurationList section */ 430 | A974F6C519AE9A7700B9AB30 /* Build configuration list for PBXProject "SwiftJSONParser" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | A974F6DC19AE9A7800B9AB30 /* Debug */, 434 | A974F6DD19AE9A7800B9AB30 /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | defaultConfigurationName = Release; 438 | }; 439 | A974F6DE19AE9A7800B9AB30 /* Build configuration list for PBXNativeTarget "SwiftJSONParser" */ = { 440 | isa = XCConfigurationList; 441 | buildConfigurations = ( 442 | A974F6DF19AE9A7800B9AB30 /* Debug */, 443 | A974F6E019AE9A7800B9AB30 /* Release */, 444 | ); 445 | defaultConfigurationIsVisible = 0; 446 | defaultConfigurationName = Release; 447 | }; 448 | A974F6E119AE9A7800B9AB30 /* Build configuration list for PBXNativeTarget "SwiftJSONParserTests" */ = { 449 | isa = XCConfigurationList; 450 | buildConfigurations = ( 451 | A974F6E219AE9A7800B9AB30 /* Debug */, 452 | A974F6E319AE9A7800B9AB30 /* Release */, 453 | ); 454 | defaultConfigurationIsVisible = 0; 455 | defaultConfigurationName = Release; 456 | }; 457 | /* End XCConfigurationList section */ 458 | }; 459 | rootObject = A974F6C219AE9A7700B9AB30 /* Project object */; 460 | } 461 | -------------------------------------------------------------------------------- /Example/JSONParserExample/SwiftJSONParser.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/JSONParserExample/SwiftJSONParser.xcodeproj/xcshareddata/xcschemes/SwiftJSONParserTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Mike Rapadas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Parse JSON like a badass 2 | 3 | ### Full disclaimer regarding performance 4 | 5 | For production apps (or if you care about efficiency at all), 6 | I highly recommend using [SwiftyJSON](https://github.com/SwiftyJSON/SwiftyJSON) 7 | over this library. After benchmarking, I found that SwiftJSONParser could be 8 | up to 7x slower than SwiftyJSON. 9 | 10 | ### This sucks 11 | 12 | ```swift 13 | let jsonData = NSData(contentsOfURL: NSURL(string: url)) 14 | var jsonErrorOptional: NSError? 15 | let jsonOptional: AnyObject! = NSJSONSerialization.JSONObjectWithData(jsonData, options: NSJSONReadingOptions(0), error: &jsonErrorOptional) 16 | 17 | if let json = jsonOptional as? Dictionary { 18 | if let other = json["other"] as? Dictionary { 19 | if let nicknames = other["nicknames"] as? Array { 20 | if let handle = nicknames[0] as AnyObject? as? String { 21 | println("Some folks call me \(handle)") 22 | } 23 | } 24 | } 25 | } 26 | ``` 27 | 28 | ### This is readable 29 | 30 | ```swift 31 | let jsonData = NSData(contentsOfURL: NSURL(string: url)) 32 | let parser = JSONParser(jsonData) 33 | 34 | if let handle = parser.getString("other.nicknames[0]") { 35 | println("Some folks call me \(handle)") 36 | } 37 | ``` 38 | 39 | 40 | ## Usage 41 | 42 | Sample JSON payload we want to parse 43 | 44 | { 45 | "name": "Mike", 46 | "favorite_number": 19, 47 | "gpa": 2.6, 48 | "favorite_things": ["Github", 42, 98.6], 49 | "other": { 50 | "city": "San Francisco", 51 | "commit_count": 9000, 52 | "nicknames": ["mrap", "Mikee"] 53 | } 54 | } 55 | 56 | Get values of a specific type. Returns optionals 57 | 58 | ```swift 59 | if let name = parser.getString("name") { 60 | println("My name is \(name)") 61 | } 62 | 63 | if let number = parser.getInt("favorite_number") { 64 | println("\(number) is my favorite number!") 65 | } 66 | 67 | if let gpa = parser.getDouble("gpa") { 68 | println("My stellar highschool gpa was \(gpa)") 69 | } 70 | ``` 71 | 72 | Or get `AnyObject` if you're not sure 73 | 74 | ```swift 75 | if let city = parser.get("other.city") { 76 | // city will be type AnyObject 77 | } 78 | ``` 79 | 80 | Get an Array of values 81 | 82 | ```swift 83 | if let favorites = parser.getArray("favorite_things") { 84 | // favorites => ["Github", 42, 98.6] 85 | } 86 | ``` 87 | 88 | ## Error Handling 89 | 90 | If you're not sure about incoming json data, check it first 91 | 92 | ```swift 93 | let badJsonData = NSData(contentsOfURL: NSURL(string: url)) 94 | let parser = JSONParser(badJsonData) 95 | 96 | // Check for an error 97 | if parser.error != nil { 98 | // Do stuff with json 99 | } else { 100 | // Handle the error 101 | println(parser.error) 102 | } 103 | ``` 104 | 105 | ## Installation 106 | The best way to use SwiftJSONParser is to import it as a framework. 107 | 108 | 1. Clone a local copy of SwiftJSONParser in any directory you'd like. 109 | `` 110 | git clone git@github.com:mrap/SwiftJSONParser.git 111 | `` 112 | 2. Drag `SwiftJSONParser.xcodeproj` into your project's project navigator 113 | 114 | 3. Add SwiftJSONParser as a Target Dependency. 115 | - Go to your App Target > Build Phases 116 | - In Target Dependencies, press `+`, select `SwiftJSONParser` 117 | -------------------------------------------------------------------------------- /SwiftJSON/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | mrap.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /SwiftJSON/JSONPath.swift: -------------------------------------------------------------------------------- 1 | // 2 | // JSONPath.swift 3 | // SwiftJSONParser 4 | // 5 | // Created by mrap on 8/27/14. 6 | // Copyright (c) 2014 Mike Rapadas. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class JSONPath { 12 | let path: String? 13 | var pathComponents = Array() 14 | 15 | init(_ path: String?) { 16 | if let nsPath = path as NSString? { 17 | self.path = path 18 | pathComponents = nsPath.componentsSeparatedByString(".") as Array 19 | } 20 | } 21 | 22 | func popNext() -> String? { 23 | if pathComponents.isEmpty { return nil } 24 | return pathComponents.removeAtIndex(0) 25 | } 26 | 27 | class func getArrayKeyAndIndex(optionalKey: String?) -> (String?, Int?)? { 28 | if let key = optionalKey as String? { 29 | var arrayKey: String? 30 | var arrayIndex: Int? 31 | var itr = 0 32 | 33 | // Match the key of the array and the index 34 | for match in key =~ "\\w+(?=\\[)|(?<=\\w\\[)(\\d+)(?=\\])" { 35 | if (itr == 0) { 36 | arrayKey = match 37 | } else { 38 | arrayIndex = match.toInt() 39 | } 40 | ++itr 41 | } 42 | return (arrayKey, arrayIndex) 43 | } 44 | 45 | return nil 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SwiftJSON/SwiftJSONParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftJSONParser.h 3 | // SwiftJSONParser 4 | // 5 | // Created by mrap on 8/27/14. 6 | // Copyright (c) 2014 Mike Rapadas. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for SwiftJSONParser. 12 | FOUNDATION_EXPORT double SwiftJSONParserVersionNumber; 13 | 14 | //! Project version string for SwiftJSONParser. 15 | FOUNDATION_EXPORT const unsigned char SwiftJSONParserVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /SwiftJSON/SwiftJSONParser.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftJSONParser.swift 3 | // SwiftJSONParser 4 | // 5 | // Created by mrap on 8/27/14. 6 | // Copyright (c) 2014 Mike Rapadas. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | private typealias _JSON = AnyObject 12 | private typealias _JSONDictionary = Dictionary 13 | private typealias _JSONArray = Array<_JSON> 14 | 15 | private func jsonDictionary(fromData: NSData?, error: NSErrorPointer) -> _JSONDictionary? { 16 | if let data = fromData { 17 | var jsonErrorOptional: NSError? 18 | if let dict: AnyObject = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(0), error: &jsonErrorOptional) { 19 | return dict as? _JSONDictionary 20 | } 21 | } 22 | 23 | return nil 24 | } 25 | 26 | public class JSONParser { 27 | private let _json: _JSONDictionary? 28 | public let error: NSError? 29 | 30 | init() { 31 | } 32 | 33 | public init(_ data: NSData?) { 34 | if data != nil { 35 | self._json = jsonDictionary(data, &self.error) 36 | } else { 37 | self.error = NSError(domain: "com.mrap.SwiftJSONParser", code: 100, userInfo: [NSLocalizedDescriptionKey: "Parser did not have any data to parse"]) 38 | } 39 | } 40 | 41 | public func get(path: String?) -> AnyObject? { 42 | return getFinalValue(_json, withPath: JSONPath(path) ) 43 | } 44 | 45 | public func getString(path: String?) -> String? { 46 | return self.get(path) as? String 47 | } 48 | 49 | public func getInt(path: String?) -> Int? { 50 | return self.get(path) as? Int 51 | } 52 | 53 | public func getDouble(path: String?) -> Double? { 54 | return self.get(path) as? Double 55 | } 56 | 57 | public func getArray(path: String?) -> Array? { 58 | return self.get(path) as? Array 59 | } 60 | 61 | private func getFinalValue(json: _JSON?, withPath path: JSONPath) -> _JSON? { 62 | if json == nil { return nil } 63 | if let nextKey = path.popNext() { 64 | 65 | // Handle _JSONArray type here 66 | // Get the value from the array and call recursively on the child 67 | if let (arrayKey, arrayIndex) = JSONPath.getArrayKeyAndIndex(nextKey) { 68 | if arrayKey != nil && arrayIndex != nil { 69 | if let array = json![arrayKey!] as? _JSONArray { 70 | return getFinalValue(array[arrayIndex!] as _JSON, withPath: path) 71 | } 72 | } 73 | } 74 | 75 | if let value: AnyObject = json![nextKey] { 76 | return getFinalValue(value, withPath: path) 77 | } else { 78 | return nil 79 | } 80 | } 81 | 82 | return json 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /SwiftJSON/SwiftRegex.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftRegex.swift 3 | // SwiftRegex 4 | // 5 | // Created by Gregory Todd Williams on 6/7/14. 6 | // Copyright (c) 2014 Gregory Todd Williams. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | infix operator =~ {} 12 | 13 | func =~ (value : String, pattern : String) -> RegexMatchResult { 14 | var err : NSError? 15 | let nsstr = value as NSString // we use this to access the NSString methods like .length and .substringWithRange(NSRange) 16 | let options = NSRegularExpressionOptions(0) 17 | let re = NSRegularExpression(pattern: pattern, options: options, error: &err) 18 | if let e = err { 19 | return RegexMatchResult(items: []) 20 | } 21 | let all = NSRange(location: 0, length: nsstr.length) 22 | let moptions = NSMatchingOptions(0) 23 | var matches : Array = [] 24 | re!.enumerateMatchesInString(value, options: moptions, range: all) { 25 | (result : NSTextCheckingResult!, flags : NSMatchingFlags, ptr : UnsafeMutablePointer) in 26 | let string = nsstr.substringWithRange(result.range) 27 | matches.append(string) 28 | } 29 | return RegexMatchResult(items: matches) 30 | } 31 | 32 | struct RegexMatchCaptureGenerator : GeneratorType { 33 | mutating func next() -> String? { 34 | if items.isEmpty { return nil } 35 | let ret = items[0] 36 | items = items[1.. 40 | } 41 | 42 | struct RegexMatchResult : SequenceType, BooleanType { 43 | var items: Array 44 | func generate() -> RegexMatchCaptureGenerator { 45 | return RegexMatchCaptureGenerator(items: items[0.. 0 49 | } 50 | subscript (i: Int) -> String { 51 | return items[i] 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /SwiftJSONParser.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A954079719AEDDCC0076E292 /* SwiftJSONParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A974F6EE19AED6C000B9AB30 /* SwiftJSONParser.swift */; }; 11 | A954079919AEF2620076E292 /* JSONPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = A954079819AEF2620076E292 /* JSONPath.swift */; }; 12 | A954079A19AEF2620076E292 /* JSONPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = A954079819AEF2620076E292 /* JSONPath.swift */; }; 13 | A95407A719AFBCA90076E292 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95407A619AFBCA90076E292 /* SwiftRegex.swift */; }; 14 | A95407A819AFBCA90076E292 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = A95407A619AFBCA90076E292 /* SwiftRegex.swift */; }; 15 | A974F6D119AE9A7700B9AB30 /* SwiftJSONParser.h in Headers */ = {isa = PBXBuildFile; fileRef = A974F6D019AE9A7700B9AB30 /* SwiftJSONParser.h */; settings = {ATTRIBUTES = (Public, ); }; }; 16 | A974F6DB19AE9A7800B9AB30 /* SwiftJSONParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A974F6DA19AE9A7800B9AB30 /* SwiftJSONParserTests.swift */; }; 17 | A974F6ED19AEC7F700B9AB30 /* BasicTypes.json in Resources */ = {isa = PBXBuildFile; fileRef = A974F6EB19AEC6C600B9AB30 /* BasicTypes.json */; }; 18 | A974F6EF19AED6C000B9AB30 /* SwiftJSONParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = A974F6EE19AED6C000B9AB30 /* SwiftJSONParser.swift */; }; 19 | A9D3AAC51A6358940071D8A9 /* Other Parsers in Resources */ = {isa = PBXBuildFile; fileRef = A9D3AAC41A6358940071D8A9 /* Other Parsers */; }; 20 | A9D3AACA1A6358F80071D8A9 /* ParserBenchmarks.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D3AAC91A6358F80071D8A9 /* ParserBenchmarks.swift */; }; 21 | A9D3AAD01A6365500071D8A9 /* SwiftyJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9D3AACE1A6361B70071D8A9 /* SwiftyJSON.swift */; }; 22 | A9D3AAD21A6368610071D8A9 /* TweetsSearch.json in Resources */ = {isa = PBXBuildFile; fileRef = A9D3AAD11A6368610071D8A9 /* TweetsSearch.json */; }; 23 | A9F8A08119B598B1000D9907 /* ErrorHandingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9F8A08019B598B1000D9907 /* ErrorHandingTests.swift */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | A954079819AEF2620076E292 /* JSONPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSONPath.swift; sourceTree = ""; }; 28 | A95407A619AFBCA90076E292 /* SwiftRegex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftRegex.swift; sourceTree = ""; }; 29 | A974F6CB19AE9A7700B9AB30 /* SwiftJSONParser.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftJSONParser.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | A974F6CF19AE9A7700B9AB30 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | A974F6D019AE9A7700B9AB30 /* SwiftJSONParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftJSONParser.h; sourceTree = ""; }; 32 | A974F6D619AE9A7800B9AB30 /* SwiftJSONParserTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftJSONParserTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | A974F6D919AE9A7800B9AB30 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | A974F6DA19AE9A7800B9AB30 /* SwiftJSONParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftJSONParserTests.swift; sourceTree = ""; }; 35 | A974F6EB19AEC6C600B9AB30 /* BasicTypes.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = BasicTypes.json; sourceTree = ""; }; 36 | A974F6EE19AED6C000B9AB30 /* SwiftJSONParser.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; path = SwiftJSONParser.swift; sourceTree = ""; }; 37 | A9D3AAC41A6358940071D8A9 /* Other Parsers */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Other Parsers"; path = "Benchmarks/Other Parsers"; sourceTree = ""; }; 38 | A9D3AAC91A6358F80071D8A9 /* ParserBenchmarks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ParserBenchmarks.swift; path = Benchmarks/ParserBenchmarks.swift; sourceTree = ""; }; 39 | A9D3AACE1A6361B70071D8A9 /* SwiftyJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SwiftyJSON.swift; path = "SwiftJSONTests/Benchmarks/Other Parsers/SwiftyJSON/Source/SwiftyJSON.swift"; sourceTree = ""; }; 40 | A9D3AAD11A6368610071D8A9 /* TweetsSearch.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = TweetsSearch.json; sourceTree = ""; }; 41 | A9F8A08019B598B1000D9907 /* ErrorHandingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ErrorHandingTests.swift; sourceTree = ""; }; 42 | /* End PBXFileReference section */ 43 | 44 | /* Begin PBXFrameworksBuildPhase section */ 45 | A974F6C719AE9A7700B9AB30 /* Frameworks */ = { 46 | isa = PBXFrameworksBuildPhase; 47 | buildActionMask = 2147483647; 48 | files = ( 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | A974F6D319AE9A7800B9AB30 /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | /* End PBXFrameworksBuildPhase section */ 60 | 61 | /* Begin PBXGroup section */ 62 | A974F6C119AE9A7700B9AB30 = { 63 | isa = PBXGroup; 64 | children = ( 65 | A9D3AACE1A6361B70071D8A9 /* SwiftyJSON.swift */, 66 | A974F6CD19AE9A7700B9AB30 /* SwiftJSONParser */, 67 | A974F6D719AE9A7800B9AB30 /* SwiftJSONParserTests */, 68 | A974F6CC19AE9A7700B9AB30 /* Products */, 69 | ); 70 | sourceTree = ""; 71 | }; 72 | A974F6CC19AE9A7700B9AB30 /* Products */ = { 73 | isa = PBXGroup; 74 | children = ( 75 | A974F6CB19AE9A7700B9AB30 /* SwiftJSONParser.framework */, 76 | A974F6D619AE9A7800B9AB30 /* SwiftJSONParserTests.xctest */, 77 | ); 78 | name = Products; 79 | sourceTree = ""; 80 | }; 81 | A974F6CD19AE9A7700B9AB30 /* SwiftJSONParser */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | A974F6D019AE9A7700B9AB30 /* SwiftJSONParser.h */, 85 | A974F6EE19AED6C000B9AB30 /* SwiftJSONParser.swift */, 86 | A954079819AEF2620076E292 /* JSONPath.swift */, 87 | A95407A619AFBCA90076E292 /* SwiftRegex.swift */, 88 | A974F6CE19AE9A7700B9AB30 /* Supporting Files */, 89 | ); 90 | name = SwiftJSONParser; 91 | path = SwiftJSON; 92 | sourceTree = ""; 93 | }; 94 | A974F6CE19AE9A7700B9AB30 /* Supporting Files */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | A974F6CF19AE9A7700B9AB30 /* Info.plist */, 98 | ); 99 | name = "Supporting Files"; 100 | sourceTree = ""; 101 | }; 102 | A974F6D719AE9A7800B9AB30 /* SwiftJSONParserTests */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | A974F6DA19AE9A7800B9AB30 /* SwiftJSONParserTests.swift */, 106 | A9F8A08019B598B1000D9907 /* ErrorHandingTests.swift */, 107 | A974F6EA19AEC6B500B9AB30 /* Fixtures */, 108 | A974F6D819AE9A7800B9AB30 /* Supporting Files */, 109 | A9D3AAC71A6358C30071D8A9 /* Benchmarks */, 110 | ); 111 | name = SwiftJSONParserTests; 112 | path = SwiftJSONTests; 113 | sourceTree = ""; 114 | }; 115 | A974F6D819AE9A7800B9AB30 /* Supporting Files */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | A974F6D919AE9A7800B9AB30 /* Info.plist */, 119 | ); 120 | name = "Supporting Files"; 121 | sourceTree = ""; 122 | }; 123 | A974F6EA19AEC6B500B9AB30 /* Fixtures */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | A974F6EB19AEC6C600B9AB30 /* BasicTypes.json */, 127 | A9D3AAD11A6368610071D8A9 /* TweetsSearch.json */, 128 | ); 129 | name = Fixtures; 130 | sourceTree = ""; 131 | }; 132 | A9D3AAC71A6358C30071D8A9 /* Benchmarks */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | A9D3AAC91A6358F80071D8A9 /* ParserBenchmarks.swift */, 136 | A9D3AAC41A6358940071D8A9 /* Other Parsers */, 137 | ); 138 | name = Benchmarks; 139 | sourceTree = ""; 140 | }; 141 | /* End PBXGroup section */ 142 | 143 | /* Begin PBXHeadersBuildPhase section */ 144 | A974F6C819AE9A7700B9AB30 /* Headers */ = { 145 | isa = PBXHeadersBuildPhase; 146 | buildActionMask = 2147483647; 147 | files = ( 148 | A974F6D119AE9A7700B9AB30 /* SwiftJSONParser.h in Headers */, 149 | ); 150 | runOnlyForDeploymentPostprocessing = 0; 151 | }; 152 | /* End PBXHeadersBuildPhase section */ 153 | 154 | /* Begin PBXNativeTarget section */ 155 | A974F6CA19AE9A7700B9AB30 /* SwiftJSONParser */ = { 156 | isa = PBXNativeTarget; 157 | buildConfigurationList = A974F6DE19AE9A7800B9AB30 /* Build configuration list for PBXNativeTarget "SwiftJSONParser" */; 158 | buildPhases = ( 159 | A974F6C619AE9A7700B9AB30 /* Sources */, 160 | A974F6C719AE9A7700B9AB30 /* Frameworks */, 161 | A974F6C819AE9A7700B9AB30 /* Headers */, 162 | A974F6C919AE9A7700B9AB30 /* Resources */, 163 | ); 164 | buildRules = ( 165 | ); 166 | dependencies = ( 167 | ); 168 | name = SwiftJSONParser; 169 | productName = SwiftJSON; 170 | productReference = A974F6CB19AE9A7700B9AB30 /* SwiftJSONParser.framework */; 171 | productType = "com.apple.product-type.framework"; 172 | }; 173 | A974F6D519AE9A7800B9AB30 /* SwiftJSONParserTests */ = { 174 | isa = PBXNativeTarget; 175 | buildConfigurationList = A974F6E119AE9A7800B9AB30 /* Build configuration list for PBXNativeTarget "SwiftJSONParserTests" */; 176 | buildPhases = ( 177 | A974F6D219AE9A7800B9AB30 /* Sources */, 178 | A974F6D319AE9A7800B9AB30 /* Frameworks */, 179 | A974F6D419AE9A7800B9AB30 /* Resources */, 180 | ); 181 | buildRules = ( 182 | ); 183 | dependencies = ( 184 | ); 185 | name = SwiftJSONParserTests; 186 | productName = SwiftJSONTests; 187 | productReference = A974F6D619AE9A7800B9AB30 /* SwiftJSONParserTests.xctest */; 188 | productType = "com.apple.product-type.bundle.unit-test"; 189 | }; 190 | /* End PBXNativeTarget section */ 191 | 192 | /* Begin PBXProject section */ 193 | A974F6C219AE9A7700B9AB30 /* Project object */ = { 194 | isa = PBXProject; 195 | attributes = { 196 | LastUpgradeCheck = 0600; 197 | ORGANIZATIONNAME = "Mike Rapadas"; 198 | TargetAttributes = { 199 | A974F6CA19AE9A7700B9AB30 = { 200 | CreatedOnToolsVersion = 6.0; 201 | }; 202 | A974F6D519AE9A7800B9AB30 = { 203 | CreatedOnToolsVersion = 6.0; 204 | }; 205 | }; 206 | }; 207 | buildConfigurationList = A974F6C519AE9A7700B9AB30 /* Build configuration list for PBXProject "SwiftJSONParser" */; 208 | compatibilityVersion = "Xcode 3.2"; 209 | developmentRegion = English; 210 | hasScannedForEncodings = 0; 211 | knownRegions = ( 212 | en, 213 | ); 214 | mainGroup = A974F6C119AE9A7700B9AB30; 215 | productRefGroup = A974F6CC19AE9A7700B9AB30 /* Products */; 216 | projectDirPath = ""; 217 | projectRoot = ""; 218 | targets = ( 219 | A974F6CA19AE9A7700B9AB30 /* SwiftJSONParser */, 220 | A974F6D519AE9A7800B9AB30 /* SwiftJSONParserTests */, 221 | ); 222 | }; 223 | /* End PBXProject section */ 224 | 225 | /* Begin PBXResourcesBuildPhase section */ 226 | A974F6C919AE9A7700B9AB30 /* Resources */ = { 227 | isa = PBXResourcesBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | A974F6D419AE9A7800B9AB30 /* Resources */ = { 234 | isa = PBXResourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | A974F6ED19AEC7F700B9AB30 /* BasicTypes.json in Resources */, 238 | A9D3AAD21A6368610071D8A9 /* TweetsSearch.json in Resources */, 239 | A9D3AAC51A6358940071D8A9 /* Other Parsers in Resources */, 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | }; 243 | /* End PBXResourcesBuildPhase section */ 244 | 245 | /* Begin PBXSourcesBuildPhase section */ 246 | A974F6C619AE9A7700B9AB30 /* Sources */ = { 247 | isa = PBXSourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | A954079919AEF2620076E292 /* JSONPath.swift in Sources */, 251 | A974F6EF19AED6C000B9AB30 /* SwiftJSONParser.swift in Sources */, 252 | A95407A719AFBCA90076E292 /* SwiftRegex.swift in Sources */, 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | A974F6D219AE9A7800B9AB30 /* Sources */ = { 257 | isa = PBXSourcesBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | A9D3AACA1A6358F80071D8A9 /* ParserBenchmarks.swift in Sources */, 261 | A954079719AEDDCC0076E292 /* SwiftJSONParser.swift in Sources */, 262 | A974F6DB19AE9A7800B9AB30 /* SwiftJSONParserTests.swift in Sources */, 263 | A954079A19AEF2620076E292 /* JSONPath.swift in Sources */, 264 | A9F8A08119B598B1000D9907 /* ErrorHandingTests.swift in Sources */, 265 | A95407A819AFBCA90076E292 /* SwiftRegex.swift in Sources */, 266 | A9D3AAD01A6365500071D8A9 /* SwiftyJSON.swift in Sources */, 267 | ); 268 | runOnlyForDeploymentPostprocessing = 0; 269 | }; 270 | /* End PBXSourcesBuildPhase section */ 271 | 272 | /* Begin XCBuildConfiguration section */ 273 | A974F6DC19AE9A7800B9AB30 /* Debug */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | ALWAYS_SEARCH_USER_PATHS = NO; 277 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 278 | CLANG_CXX_LIBRARY = "libc++"; 279 | CLANG_ENABLE_MODULES = YES; 280 | CLANG_ENABLE_OBJC_ARC = YES; 281 | CLANG_WARN_BOOL_CONVERSION = YES; 282 | CLANG_WARN_CONSTANT_CONVERSION = YES; 283 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 284 | CLANG_WARN_EMPTY_BODY = YES; 285 | CLANG_WARN_ENUM_CONVERSION = YES; 286 | CLANG_WARN_INT_CONVERSION = YES; 287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 288 | CLANG_WARN_UNREACHABLE_CODE = YES; 289 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 290 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 291 | COPY_PHASE_STRIP = NO; 292 | CURRENT_PROJECT_VERSION = 1; 293 | ENABLE_STRICT_OBJC_MSGSEND = YES; 294 | GCC_C_LANGUAGE_STANDARD = gnu99; 295 | GCC_DYNAMIC_NO_PIC = NO; 296 | GCC_OPTIMIZATION_LEVEL = 0; 297 | GCC_PREPROCESSOR_DEFINITIONS = ( 298 | "DEBUG=1", 299 | "$(inherited)", 300 | ); 301 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 302 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 303 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 304 | GCC_WARN_UNDECLARED_SELECTOR = YES; 305 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 306 | GCC_WARN_UNUSED_FUNCTION = YES; 307 | GCC_WARN_UNUSED_VARIABLE = YES; 308 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 309 | MTL_ENABLE_DEBUG_INFO = YES; 310 | ONLY_ACTIVE_ARCH = YES; 311 | SDKROOT = iphoneos; 312 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 313 | TARGETED_DEVICE_FAMILY = "1,2"; 314 | VERSIONING_SYSTEM = "apple-generic"; 315 | VERSION_INFO_PREFIX = ""; 316 | }; 317 | name = Debug; 318 | }; 319 | A974F6DD19AE9A7800B9AB30 /* Release */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ALWAYS_SEARCH_USER_PATHS = NO; 323 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 324 | CLANG_CXX_LIBRARY = "libc++"; 325 | CLANG_ENABLE_MODULES = YES; 326 | CLANG_ENABLE_OBJC_ARC = YES; 327 | CLANG_WARN_BOOL_CONVERSION = YES; 328 | CLANG_WARN_CONSTANT_CONVERSION = YES; 329 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 330 | CLANG_WARN_EMPTY_BODY = YES; 331 | CLANG_WARN_ENUM_CONVERSION = YES; 332 | CLANG_WARN_INT_CONVERSION = YES; 333 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 334 | CLANG_WARN_UNREACHABLE_CODE = YES; 335 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 336 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 337 | COPY_PHASE_STRIP = YES; 338 | CURRENT_PROJECT_VERSION = 1; 339 | ENABLE_NS_ASSERTIONS = NO; 340 | ENABLE_STRICT_OBJC_MSGSEND = YES; 341 | GCC_C_LANGUAGE_STANDARD = gnu99; 342 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 343 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 344 | GCC_WARN_UNDECLARED_SELECTOR = YES; 345 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 346 | GCC_WARN_UNUSED_FUNCTION = YES; 347 | GCC_WARN_UNUSED_VARIABLE = YES; 348 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 349 | MTL_ENABLE_DEBUG_INFO = NO; 350 | SDKROOT = iphoneos; 351 | TARGETED_DEVICE_FAMILY = "1,2"; 352 | VALIDATE_PRODUCT = YES; 353 | VERSIONING_SYSTEM = "apple-generic"; 354 | VERSION_INFO_PREFIX = ""; 355 | }; 356 | name = Release; 357 | }; 358 | A974F6DF19AE9A7800B9AB30 /* Debug */ = { 359 | isa = XCBuildConfiguration; 360 | buildSettings = { 361 | CLANG_ENABLE_MODULES = YES; 362 | DEFINES_MODULE = YES; 363 | DYLIB_COMPATIBILITY_VERSION = 1; 364 | DYLIB_CURRENT_VERSION = 1; 365 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 366 | INFOPLIST_FILE = SwiftJSON/Info.plist; 367 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 368 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 369 | PRODUCT_NAME = SwiftJSONParser; 370 | SKIP_INSTALL = YES; 371 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 372 | }; 373 | name = Debug; 374 | }; 375 | A974F6E019AE9A7800B9AB30 /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | CLANG_ENABLE_MODULES = YES; 379 | DEFINES_MODULE = YES; 380 | DYLIB_COMPATIBILITY_VERSION = 1; 381 | DYLIB_CURRENT_VERSION = 1; 382 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 383 | INFOPLIST_FILE = SwiftJSON/Info.plist; 384 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 385 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 386 | PRODUCT_NAME = SwiftJSONParser; 387 | SKIP_INSTALL = YES; 388 | }; 389 | name = Release; 390 | }; 391 | A974F6E219AE9A7800B9AB30 /* Debug */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | FRAMEWORK_SEARCH_PATHS = ( 395 | "$(SDKROOT)/Developer/Library/Frameworks", 396 | "$(inherited)", 397 | "$(PROJECT_DIR)/SwiftJSONTests/Benchmarks/Other", 398 | "Parsers/SwiftyJSON/build/Debug-iphoneos", 399 | ); 400 | GCC_PREPROCESSOR_DEFINITIONS = ( 401 | "DEBUG=1", 402 | "$(inherited)", 403 | ); 404 | INFOPLIST_FILE = SwiftJSONTests/Info.plist; 405 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 406 | PRODUCT_NAME = SwiftJSONParserTests; 407 | SWIFT_INCLUDE_PATHS = ""; 408 | }; 409 | name = Debug; 410 | }; 411 | A974F6E319AE9A7800B9AB30 /* Release */ = { 412 | isa = XCBuildConfiguration; 413 | buildSettings = { 414 | FRAMEWORK_SEARCH_PATHS = ( 415 | "$(SDKROOT)/Developer/Library/Frameworks", 416 | "$(inherited)", 417 | "$(PROJECT_DIR)/SwiftJSONTests/Benchmarks/Other", 418 | "Parsers/SwiftyJSON/build/Debug-iphoneos", 419 | ); 420 | INFOPLIST_FILE = SwiftJSONTests/Info.plist; 421 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 422 | PRODUCT_NAME = SwiftJSONParserTests; 423 | SWIFT_INCLUDE_PATHS = ""; 424 | }; 425 | name = Release; 426 | }; 427 | /* End XCBuildConfiguration section */ 428 | 429 | /* Begin XCConfigurationList section */ 430 | A974F6C519AE9A7700B9AB30 /* Build configuration list for PBXProject "SwiftJSONParser" */ = { 431 | isa = XCConfigurationList; 432 | buildConfigurations = ( 433 | A974F6DC19AE9A7800B9AB30 /* Debug */, 434 | A974F6DD19AE9A7800B9AB30 /* Release */, 435 | ); 436 | defaultConfigurationIsVisible = 0; 437 | defaultConfigurationName = Release; 438 | }; 439 | A974F6DE19AE9A7800B9AB30 /* Build configuration list for PBXNativeTarget "SwiftJSONParser" */ = { 440 | isa = XCConfigurationList; 441 | buildConfigurations = ( 442 | A974F6DF19AE9A7800B9AB30 /* Debug */, 443 | A974F6E019AE9A7800B9AB30 /* Release */, 444 | ); 445 | defaultConfigurationIsVisible = 0; 446 | defaultConfigurationName = Release; 447 | }; 448 | A974F6E119AE9A7800B9AB30 /* Build configuration list for PBXNativeTarget "SwiftJSONParserTests" */ = { 449 | isa = XCConfigurationList; 450 | buildConfigurations = ( 451 | A974F6E219AE9A7800B9AB30 /* Debug */, 452 | A974F6E319AE9A7800B9AB30 /* Release */, 453 | ); 454 | defaultConfigurationIsVisible = 0; 455 | defaultConfigurationName = Release; 456 | }; 457 | /* End XCConfigurationList section */ 458 | }; 459 | rootObject = A974F6C219AE9A7700B9AB30 /* Project object */; 460 | } 461 | -------------------------------------------------------------------------------- /SwiftJSONParser.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftJSONParser.xcodeproj/xcshareddata/xcschemes/SwiftJSONParserTests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /SwiftJSONTests/BasicTypes.json: -------------------------------------------------------------------------------- 1 | { 2 | "keyForString": "string", 3 | "keyForInt": 42, 4 | "keyForDouble": 98.6, 5 | "keyForArray": ["string", 42, 98.6], 6 | "nested": { 7 | "keyForString": "string", 8 | "keyForInt": 42, 9 | "keyForDouble": 98.6, 10 | "keyForArray": ["string", 42, 98.6], 11 | "nested": { 12 | "keyForString": "string", 13 | "keyForInt": 42, 14 | "keyForDouble": 98.6, 15 | "keyForArray": ["string", 42, 98.6] 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /SwiftJSONTests/Benchmarks/ParserBenchmarks.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ParserBenchmarks.swift 3 | // SwiftJSONParser 4 | // 5 | // Created by mrap on 1/11/15. 6 | // Copyright (c) 2015 Mike Rapadas. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class ParserBenchmarks: XCTestCase { 13 | 14 | var data: NSData? 15 | var tweetData: NSData? 16 | let iterations = 10000; 17 | 18 | override func setUp() { 19 | super.setUp() 20 | 21 | if let path = NSBundle(forClass: SwiftJSONParserTests.self).pathForResource("BasicTypes", ofType: "json") { 22 | var error: NSError? 23 | self.data = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: &error) 24 | } 25 | 26 | if let path = NSBundle(forClass: SwiftJSONParserTests.self).pathForResource("TweetsSearch", ofType: "json") { 27 | var error: NSError? 28 | self.tweetData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: &error) 29 | } 30 | } 31 | 32 | override func tearDown() { 33 | // Put teardown code here. This method is called after the invocation of each test method in the class. 34 | super.tearDown() 35 | } 36 | 37 | func benchmark(fn: ()->Void) { 38 | self.measureBlock() { 39 | for i in 0...self.iterations { 40 | fn(); 41 | } 42 | } 43 | } 44 | 45 | func testParserInit() { 46 | benchmark() { 47 | let parser = JSONParser(self.tweetData) 48 | } 49 | } 50 | 51 | func testSwiftyInit() { 52 | benchmark() { 53 | let swifty = JSON(data: self.tweetData!) 54 | } 55 | } 56 | 57 | func testParserString() { 58 | let parser = JSONParser(self.data) 59 | benchmark() { 60 | if let val = parser.getString("keyForString") { 61 | XCTAssertEqual(val, "string", "Not expected value") 62 | } else { 63 | XCTFail("Should have string value"); 64 | } 65 | } 66 | } 67 | 68 | func testSwiftyString() { 69 | let swifty = JSON(data: self.data!) 70 | benchmark() { 71 | if let val = swifty["keyForString"].string { 72 | XCTAssertEqual(val, "string", "Not expected value") 73 | } else { 74 | XCTFail("Should have string value"); 75 | } 76 | } 77 | } 78 | 79 | func testParserNestedString() { 80 | let parser = JSONParser(self.data) 81 | benchmark() { 82 | if let val = parser.getString("nested.keyForString") { 83 | XCTAssertEqual(val, "string", "Not expected value") 84 | } else { 85 | XCTFail("Should have string value"); 86 | } 87 | } 88 | } 89 | 90 | func testSwiftyNestedString() { 91 | let swifty = JSON(data: self.data!) 92 | benchmark() { 93 | if let val = swifty["nested"]["keyForString"].string { 94 | XCTAssertEqual(val, "string", "Not expected value") 95 | } else { 96 | XCTFail("Should have string value"); 97 | } 98 | } 99 | } 100 | 101 | func testParserNestedArrayString() { 102 | let parser = JSONParser(self.data) 103 | benchmark() { 104 | if let val = parser.getString("nested.keyForArray[0]") { 105 | XCTAssertEqual(val, "string", "Not expected value") 106 | } else { 107 | XCTFail("Should have string value"); 108 | } 109 | } 110 | } 111 | 112 | func testSwiftyNestedArrayString() { 113 | let swifty = JSON(data: self.data!) 114 | benchmark() { 115 | if let val = swifty["nested"]["keyForArray"][0].string { 116 | XCTAssertEqual(val, "string", "Not expected value") 117 | } else { 118 | XCTFail("Should have string value"); 119 | } 120 | } 121 | } 122 | 123 | func testParserNestedNestedString() { 124 | let parser = JSONParser(self.data) 125 | benchmark() { 126 | if let val = parser.getString("nested.nested.keyForString") { 127 | XCTAssertEqual(val, "string", "Not expected value") 128 | } else { 129 | XCTFail("Should have string value"); 130 | } 131 | } 132 | } 133 | 134 | func testSwiftyNestedNestedString() { 135 | let swifty = JSON(data: self.data!) 136 | benchmark() { 137 | if let val = swifty["nested"]["nested"]["keyForString"].string { 138 | XCTAssertEqual(val, "string", "Not expected value") 139 | } else { 140 | XCTFail("Should have string value"); 141 | } 142 | } 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /SwiftJSONTests/ErrorHandingTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ErrorHandlingTests.swift 3 | // SwiftJSONParserTests 4 | // 5 | // Created by mrap on 9/1/14. 6 | // Copyright (c) 2014 Mike Rapadas. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class ErrorHandlingTests: XCTestCase { 13 | func testNilData() { 14 | let parser = JSONParser(nil) 15 | XCTAssertNotNil(parser.error, "Parser should have an error") 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SwiftJSONTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | mrap.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftJSONTests/SwiftJSONParserTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftJSONParserTests.swift 3 | // SwiftJSONParserTests 4 | // 5 | // Created by mrap on 8/27/14. 6 | // Copyright (c) 2014 Mike Rapadas. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class SwiftJSONParserTests: XCTestCase { 13 | 14 | var data: NSData? 15 | var parser = JSONParser() 16 | 17 | override func setUp() { 18 | super.setUp() 19 | 20 | if let path = NSBundle(forClass: SwiftJSONParserTests.self).pathForResource("BasicTypes", ofType: "json") { 21 | var error: NSError? 22 | self.data = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: &error) 23 | XCTAssertNil(error, "Got error reading json file") 24 | XCTAssertNotNil(data, "JSON data should not be nil") 25 | self.parser = JSONParser(data) 26 | XCTAssertNil(parser.error, "Parser should not have an error") 27 | } 28 | } 29 | 30 | override func tearDown() { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | super.tearDown() 33 | } 34 | 35 | func testGetStringValue() { 36 | if let value = parser.getString("keyForString") { 37 | XCTAssertEqual(value, "string", "Should return a String value") 38 | } else { 39 | XCTFail("Value should not be nil") 40 | } 41 | } 42 | 43 | func testGetNestedStringValue() { 44 | if let value = parser.getString("nested.keyForString") { 45 | XCTAssertEqual(value, "string", "Should return a String value") 46 | } else { 47 | XCTFail("Value should not be nil") 48 | } 49 | } 50 | 51 | func testGetIntValue() { 52 | if let value = parser.getInt("keyForInt") { 53 | XCTAssertEqual(value, 42, "Should return an Int value") 54 | } else { 55 | XCTFail("Value should not be nil") 56 | } 57 | } 58 | 59 | func testGetNestedIntValue() { 60 | if let value = parser.getInt("nested.keyForInt") { 61 | XCTAssertEqual(value, 42, "Should return an Int value") 62 | } else { 63 | XCTFail("Value should not be nil") 64 | } 65 | } 66 | 67 | func testGetDoubleValue() { 68 | if let value = parser.getDouble("keyForDouble") { 69 | XCTAssertEqual(value, 98.6, "Should return an Double value") 70 | } else { 71 | XCTFail("Value should not be nil") 72 | } 73 | } 74 | 75 | func testGetNestedDoubleValue() { 76 | if let value = parser.getDouble("nested.keyForDouble") { 77 | XCTAssertEqual(value, 98.6, "Should return an Double value") 78 | } else { 79 | XCTFail("Value should not be nil") 80 | } 81 | } 82 | 83 | func testGetArrayValues() { 84 | if let stringValue = parser.getString("keyForArray[0]") { 85 | XCTAssertEqual(stringValue, "string", "Should return a String value") 86 | } else { 87 | XCTFail("Value should not be nil") 88 | } 89 | 90 | if let intValue = parser.getInt("keyForArray[1]") { 91 | XCTAssertEqual(intValue, 42, "Should return a Int value") 92 | } else { 93 | XCTFail("Value should not be nil") 94 | } 95 | 96 | if let doubleValue = parser.getDouble("keyForArray[2]") { 97 | XCTAssertEqual(doubleValue, 98.6, "Should return a Double value") 98 | } else { 99 | XCTFail("Value should not be nil") 100 | } 101 | } 102 | 103 | func testGetArray() { 104 | if let array = parser.getArray("keyForArray") as? [NSObject] { 105 | let expected = ["string", 42, 98.6] 106 | XCTAssertEqual(array, expected, "Should return an Array containing correct values") 107 | } else { 108 | XCTFail("Value should not be nil") 109 | } 110 | } 111 | 112 | func testNotReturnFalsePositive() { 113 | if let nonExistent: AnyObject = parser.get("other.nonExistentKey") { 114 | XCTFail("Value should not be nil") 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /SwiftJSONTests/TweetsSearch.json: -------------------------------------------------------------------------------- 1 | { 2 | "statuses": [ 3 | { 4 | "coordinates": null, 5 | "favorited": false, 6 | "truncated": false, 7 | "created_at": "Mon Sep 24 03:35:21 +0000 2012", 8 | "id_str": "250075927172759552", 9 | "entities": { 10 | "urls": [ 11 | 12 | ], 13 | "hashtags": [ 14 | { 15 | "text": "freebandnames", 16 | "indices": [ 17 | 20, 18 | 34 19 | ] 20 | } 21 | ], 22 | "user_mentions": [ 23 | 24 | ] 25 | }, 26 | "in_reply_to_user_id_str": null, 27 | "contributors": null, 28 | "text": "Aggressive Ponytail #freebandnames", 29 | "metadata": { 30 | "iso_language_code": "en", 31 | "result_type": "recent" 32 | }, 33 | "retweet_count": 0, 34 | "in_reply_to_status_id_str": null, 35 | "id": 250075927172759552, 36 | "geo": null, 37 | "retweeted": false, 38 | "in_reply_to_user_id": null, 39 | "place": null, 40 | "user": { 41 | "profile_sidebar_fill_color": "DDEEF6", 42 | "profile_sidebar_border_color": "C0DEED", 43 | "profile_background_tile": false, 44 | "name": "Sean Cummings", 45 | "profile_image_url": "http://a0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg", 46 | "created_at": "Mon Apr 26 06:01:55 +0000 2010", 47 | "location": "LA, CA", 48 | "follow_request_sent": null, 49 | "profile_link_color": "0084B4", 50 | "is_translator": false, 51 | "id_str": "137238150", 52 | "entities": { 53 | "url": { 54 | "urls": [ 55 | { 56 | "expanded_url": null, 57 | "url": "", 58 | "indices": [ 59 | 0, 60 | 0 61 | ] 62 | } 63 | ] 64 | }, 65 | "description": { 66 | "urls": [ 67 | 68 | ] 69 | } 70 | }, 71 | "default_profile": true, 72 | "contributors_enabled": false, 73 | "favourites_count": 0, 74 | "url": null, 75 | "profile_image_url_https": "https://si0.twimg.com/profile_images/2359746665/1v6zfgqo8g0d3mk7ii5s_normal.jpeg", 76 | "utc_offset": -28800, 77 | "id": 137238150, 78 | "profile_use_background_image": true, 79 | "listed_count": 2, 80 | "profile_text_color": "333333", 81 | "lang": "en", 82 | "followers_count": 70, 83 | "protected": false, 84 | "notifications": null, 85 | "profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme1/bg.png", 86 | "profile_background_color": "C0DEED", 87 | "verified": false, 88 | "geo_enabled": true, 89 | "time_zone": "Pacific Time (US & Canada)", 90 | "description": "Born 330 Live 310", 91 | "default_profile_image": false, 92 | "profile_background_image_url": "http://a0.twimg.com/images/themes/theme1/bg.png", 93 | "statuses_count": 579, 94 | "friends_count": 110, 95 | "following": null, 96 | "show_all_inline_media": false, 97 | "screen_name": "sean_cummings" 98 | }, 99 | "in_reply_to_screen_name": null, 100 | "source": "Twitter for Mac", 101 | "in_reply_to_status_id": null 102 | }, 103 | { 104 | "coordinates": null, 105 | "favorited": false, 106 | "truncated": false, 107 | "created_at": "Fri Sep 21 23:40:54 +0000 2012", 108 | "id_str": "249292149810667520", 109 | "entities": { 110 | "urls": [ 111 | 112 | ], 113 | "hashtags": [ 114 | { 115 | "text": "FreeBandNames", 116 | "indices": [ 117 | 20, 118 | 34 119 | ] 120 | } 121 | ], 122 | "user_mentions": [ 123 | 124 | ] 125 | }, 126 | "in_reply_to_user_id_str": null, 127 | "contributors": null, 128 | "text": "Thee Namaste Nerdz. #FreeBandNames", 129 | "metadata": { 130 | "iso_language_code": "pl", 131 | "result_type": "recent" 132 | }, 133 | "retweet_count": 0, 134 | "in_reply_to_status_id_str": null, 135 | "id": 249292149810667520, 136 | "geo": null, 137 | "retweeted": false, 138 | "in_reply_to_user_id": null, 139 | "place": null, 140 | "user": { 141 | "profile_sidebar_fill_color": "DDFFCC", 142 | "profile_sidebar_border_color": "BDDCAD", 143 | "profile_background_tile": true, 144 | "name": "Chaz Martenstein", 145 | "profile_image_url": "http://a0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg", 146 | "created_at": "Tue Apr 07 19:05:07 +0000 2009", 147 | "location": "Durham, NC", 148 | "follow_request_sent": null, 149 | "profile_link_color": "0084B4", 150 | "is_translator": false, 151 | "id_str": "29516238", 152 | "entities": { 153 | "url": { 154 | "urls": [ 155 | { 156 | "expanded_url": null, 157 | "url": "http://bullcityrecords.com/wnng/", 158 | "indices": [ 159 | 0, 160 | 32 161 | ] 162 | } 163 | ] 164 | }, 165 | "description": { 166 | "urls": [ 167 | 168 | ] 169 | } 170 | }, 171 | "default_profile": false, 172 | "contributors_enabled": false, 173 | "favourites_count": 8, 174 | "url": "http://bullcityrecords.com/wnng/", 175 | "profile_image_url_https": "https://si0.twimg.com/profile_images/447958234/Lichtenstein_normal.jpg", 176 | "utc_offset": -18000, 177 | "id": 29516238, 178 | "profile_use_background_image": true, 179 | "listed_count": 118, 180 | "profile_text_color": "333333", 181 | "lang": "en", 182 | "followers_count": 2052, 183 | "protected": false, 184 | "notifications": null, 185 | "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/9423277/background_tile.bmp", 186 | "profile_background_color": "9AE4E8", 187 | "verified": false, 188 | "geo_enabled": false, 189 | "time_zone": "Eastern Time (US & Canada)", 190 | "description": "You will come to Durham, North Carolina. I will sell you some records then, here in Durham, North Carolina. Fun will happen.", 191 | "default_profile_image": false, 192 | "profile_background_image_url": "http://a0.twimg.com/profile_background_images/9423277/background_tile.bmp", 193 | "statuses_count": 7579, 194 | "friends_count": 348, 195 | "following": null, 196 | "show_all_inline_media": true, 197 | "screen_name": "bullcityrecords" 198 | }, 199 | "in_reply_to_screen_name": null, 200 | "source": "web", 201 | "in_reply_to_status_id": null 202 | }, 203 | { 204 | "coordinates": null, 205 | "favorited": false, 206 | "truncated": false, 207 | "created_at": "Fri Sep 21 23:30:20 +0000 2012", 208 | "id_str": "249289491129438208", 209 | "entities": { 210 | "urls": [ 211 | 212 | ], 213 | "hashtags": [ 214 | { 215 | "text": "freebandnames", 216 | "indices": [ 217 | 29, 218 | 43 219 | ] 220 | } 221 | ], 222 | "user_mentions": [ 223 | 224 | ] 225 | }, 226 | "in_reply_to_user_id_str": null, 227 | "contributors": null, 228 | "text": "Mexican Heaven, Mexican Hell #freebandnames", 229 | "metadata": { 230 | "iso_language_code": "en", 231 | "result_type": "recent" 232 | }, 233 | "retweet_count": 0, 234 | "in_reply_to_status_id_str": null, 235 | "id": 249289491129438208, 236 | "geo": null, 237 | "retweeted": false, 238 | "in_reply_to_user_id": null, 239 | "place": null, 240 | "user": { 241 | "profile_sidebar_fill_color": "99CC33", 242 | "profile_sidebar_border_color": "829D5E", 243 | "profile_background_tile": false, 244 | "name": "Thomas John Wakeman", 245 | "profile_image_url": "http://a0.twimg.com/profile_images/2219333930/Froggystyle_normal.png", 246 | "created_at": "Tue Sep 01 21:21:35 +0000 2009", 247 | "location": "Kingston New York", 248 | "follow_request_sent": null, 249 | "profile_link_color": "D02B55", 250 | "is_translator": false, 251 | "id_str": "70789458", 252 | "entities": { 253 | "url": { 254 | "urls": [ 255 | { 256 | "expanded_url": null, 257 | "url": "", 258 | "indices": [ 259 | 0, 260 | 0 261 | ] 262 | } 263 | ] 264 | }, 265 | "description": { 266 | "urls": [ 267 | 268 | ] 269 | } 270 | }, 271 | "default_profile": false, 272 | "contributors_enabled": false, 273 | "favourites_count": 19, 274 | "url": null, 275 | "profile_image_url_https": "https://si0.twimg.com/profile_images/2219333930/Froggystyle_normal.png", 276 | "utc_offset": -18000, 277 | "id": 70789458, 278 | "profile_use_background_image": true, 279 | "listed_count": 1, 280 | "profile_text_color": "3E4415", 281 | "lang": "en", 282 | "followers_count": 63, 283 | "protected": false, 284 | "notifications": null, 285 | "profile_background_image_url_https": "https://si0.twimg.com/images/themes/theme5/bg.gif", 286 | "profile_background_color": "352726", 287 | "verified": false, 288 | "geo_enabled": false, 289 | "time_zone": "Eastern Time (US & Canada)", 290 | "description": "Science Fiction Writer, sort of. Likes Superheroes, Mole People, Alt. Timelines.", 291 | "default_profile_image": false, 292 | "profile_background_image_url": "http://a0.twimg.com/images/themes/theme5/bg.gif", 293 | "statuses_count": 1048, 294 | "friends_count": 63, 295 | "following": null, 296 | "show_all_inline_media": false, 297 | "screen_name": "MonkiesFist" 298 | }, 299 | "in_reply_to_screen_name": null, 300 | "source": "web", 301 | "in_reply_to_status_id": null 302 | }, 303 | { 304 | "coordinates": null, 305 | "favorited": false, 306 | "truncated": false, 307 | "created_at": "Fri Sep 21 22:51:18 +0000 2012", 308 | "id_str": "249279667666817024", 309 | "entities": { 310 | "urls": [ 311 | 312 | ], 313 | "hashtags": [ 314 | { 315 | "text": "freebandnames", 316 | "indices": [ 317 | 20, 318 | 34 319 | ] 320 | } 321 | ], 322 | "user_mentions": [ 323 | 324 | ] 325 | }, 326 | "in_reply_to_user_id_str": null, 327 | "contributors": null, 328 | "text": "The Foolish Mortals #freebandnames", 329 | "metadata": { 330 | "iso_language_code": "en", 331 | "result_type": "recent" 332 | }, 333 | "retweet_count": 0, 334 | "in_reply_to_status_id_str": null, 335 | "id": 249279667666817024, 336 | "geo": null, 337 | "retweeted": false, 338 | "in_reply_to_user_id": null, 339 | "place": null, 340 | "user": { 341 | "profile_sidebar_fill_color": "BFAC83", 342 | "profile_sidebar_border_color": "615A44", 343 | "profile_background_tile": true, 344 | "name": "Marty Elmer", 345 | "profile_image_url": "http://a0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png", 346 | "created_at": "Mon May 04 00:05:00 +0000 2009", 347 | "location": "Wisconsin, USA", 348 | "follow_request_sent": null, 349 | "profile_link_color": "3B2A26", 350 | "is_translator": false, 351 | "id_str": "37539828", 352 | "entities": { 353 | "url": { 354 | "urls": [ 355 | { 356 | "expanded_url": null, 357 | "url": "http://www.omnitarian.me", 358 | "indices": [ 359 | 0, 360 | 24 361 | ] 362 | } 363 | ] 364 | }, 365 | "description": { 366 | "urls": [ 367 | 368 | ] 369 | } 370 | }, 371 | "default_profile": false, 372 | "contributors_enabled": false, 373 | "favourites_count": 647, 374 | "url": "http://www.omnitarian.me", 375 | "profile_image_url_https": "https://si0.twimg.com/profile_images/1629790393/shrinker_2000_trans_normal.png", 376 | "utc_offset": -21600, 377 | "id": 37539828, 378 | "profile_use_background_image": true, 379 | "listed_count": 52, 380 | "profile_text_color": "000000", 381 | "lang": "en", 382 | "followers_count": 608, 383 | "protected": false, 384 | "notifications": null, 385 | "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/106455659/rect6056-9.png", 386 | "profile_background_color": "EEE3C4", 387 | "verified": false, 388 | "geo_enabled": false, 389 | "time_zone": "Central Time (US & Canada)", 390 | "description": "Cartoonist, Illustrator, and T-Shirt connoisseur", 391 | "default_profile_image": false, 392 | "profile_background_image_url": "http://a0.twimg.com/profile_background_images/106455659/rect6056-9.png", 393 | "statuses_count": 3575, 394 | "friends_count": 249, 395 | "following": null, 396 | "show_all_inline_media": true, 397 | "screen_name": "Omnitarian" 398 | }, 399 | "in_reply_to_screen_name": null, 400 | "source": "Twitter for iPhone", 401 | "in_reply_to_status_id": null 402 | } 403 | ], 404 | "search_metadata": { 405 | "max_id": 250126199840518145, 406 | "since_id": 24012619984051000, 407 | "refresh_url": "?since_id=250126199840518145&q=%23freebandnames&result_type=mixed&include_entities=1", 408 | "next_results": "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed", 409 | "count": 4, 410 | "completed_in": 0.035, 411 | "since_id_str": "24012619984051000", 412 | "query": "%23freebandnames", 413 | "max_id_str": "250126199840518145" 414 | } 415 | } --------------------------------------------------------------------------------