Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
e43f400
Change key to index for array
KyleMay Oct 22, 2015
4895d37
Fix formatting issues in README
RohanNagar Oct 22, 2015
ddf8244
update pod specs
Oct 26, 2015
e61f690
Merge pull request #371 from RohanNagar/patch-1
aemaeth-me Oct 26, 2015
7ab4607
Merge pull request #370 from KyleMay/master
aemaeth-me Oct 26, 2015
5f5d00d
We do return true if the JSON is neither an Array nor a Dictionary
Oct 26, 2015
662fff1
Adding Support for Custom JSONSubscriptType
zhigang1992 Oct 28, 2015
61c4723
Merge branch 'xcode7.1'
zhigang1992 Oct 30, 2015
21ba023
Update Travis Config
zhigang1992 Oct 30, 2015
e5a5efb
Add back device specs
zhigang1992 Oct 30, 2015
ab0ddba
Adding tvOS and OSX
zhigang1992 Oct 30, 2015
def6ca6
Removing tvOS tests for now
zhigang1992 Oct 30, 2015
37ffd5d
Add tvOS
zhigang1992 Oct 31, 2015
684ceb6
Merge pull request #381 from zhigang1992/UpdateTravisCI
zhigang1992 Oct 31, 2015
28fdb86
Add Travis CI Icon
zhigang1992 Oct 31, 2015
646f7e8
Fix Typo
zhigang1992 Oct 31, 2015
fd5fac5
Rename it to JSONKey
zhigang1992 Oct 31, 2015
df8ecbc
Add Playground File
zhigang1992 Nov 1, 2015
07afaaa
Fix Example Target Build
zhigang1992 Nov 1, 2015
91d77eb
Merge pull request #376 from zhigang1992/AddingJSONSubscriptKey
zhigang1992 Nov 1, 2015
92b27d3
Merge pull request #383 from zhigang1992/FixExapmleProjectCompile
zhigang1992 Nov 1, 2015
ece271a
Merge pull request #384 from zhigang1992/AddPlayground
zhigang1992 Nov 1, 2015
4c45c92
Sets UIRequiredDeviceCapabilities for tvOS target
simonbs Nov 10, 2015
d92b1bd
fixed Alamofire & SwiftJSON integration example
erez-rabih Nov 11, 2015
bc6223c
use safe unwrapping for result value
erez-rabih Nov 12, 2015
141c48b
Merge pull request #398 from nanit/fix-alamofire-readme
zhigang1992 Nov 13, 2015
10f6790
Merge pull request #396 from simonbs/master
zhigang1992 Nov 13, 2015
88e5723
Deleted Framework search paths for target OSX Test
Nov 18, 2015
48939ee
Correct JSON's type specification URL
azone Nov 20, 2015
bfbc948
Remove force-unwrapped indicator from constants
bcapps Nov 24, 2015
0f88e65
Uses optional binding to remove force unwrapping
bcapps Nov 24, 2015
d4bf9f1
Utilizes existing optional binding to stop force unwrapping
bcapps Nov 24, 2015
ea2696e
Nil coalesce instead of force unwrap
bcapps Nov 24, 2015
9181c7c
fixes Bool case to return expected value
bcapps Nov 24, 2015
b4fb0c4
Merge pull request #401 from bcapps/optional-binding
zhigang1992 Nov 24, 2015
9b0292f
Merge pull request #400 from azone/patch-1
zhigang1992 Nov 24, 2015
b325794
Keep NSNumber Operator Internal
zhigang1992 Nov 24, 2015
98c8da9
Merge pull request #399 from hibento/master
zhigang1992 Nov 24, 2015
5ccffc1
Merge pull request #402 from zhigang1992/FixNumberOperator
zhigang1992 Nov 24, 2015
ae73ec1
Update codesign identity
diogoguimaraes Nov 25, 2015
298feb4
Add Parse as JSON.parse
zhigang1992 Nov 26, 2015
0608805
Merge pull request #406 from zhigang1992/AddInitWithString
zhigang1992 Nov 26, 2015
a4cce2e
Merge pull request #405 from seegno-forks/support/update-codesign-ide…
zhigang1992 Nov 26, 2015
4d05047
update pod specs
zhigang1992 Dec 3, 2015
a135603
add Package.swift
aemaeth-me Dec 4, 2015
8e618c8
Update README.md
aemaeth-me Dec 4, 2015
1ddae13
Use minimumCapacity parameter to optimize dictionary creations
Adlai-Holler Dec 9, 2015
6003466
set the watch os deployment target to watchOs 2.0 - otherwise it woul…
AlexanderNey Dec 9, 2015
7620d5b
Programmatically set current tag
nanoxd Dec 21, 2015
5f59648
Update optimization level to "-Ofast"
LukeTangPL Dec 29, 2015
9b961a0
Merge remote-tracking branch 'SwiftyJSON/master'
saagarjha Jan 6, 2016
baf8c18
Changed "Mac OS X" to "OS X"
saagarjha Jan 6, 2016
af8924f
Merge pull request #432 from saagarjha/master
zhigang1992 Jan 12, 2016
929539e
Merge pull request #427 from nanoxd/master
zhigang1992 Jan 12, 2016
cbeddbc
Update README.md
danipralea Jan 12, 2016
d814977
Merge pull request #437 from danipralea/patch-1
zhigang1992 Jan 27, 2016
42bdb10
Merge pull request #420 from AlexanderNey/fix/watchos2-build-target-fix
zhigang1992 Jan 28, 2016
64b832c
Changed from .empty to .isEmpty
kandelvijaya Jan 28, 2016
49f588e
Which's -> whose and typo fix in comments
kandelvijaya Jan 31, 2016
5fc4545
Rename isExists to exists. Fixes #448
CraigSiemens Feb 17, 2016
20ee3ed
Replace ++ with +=
Mar 1, 2016
9858784
Merge pull request #419 from Adlai-Holler/ReserveCapacity
aemaeth-me Mar 15, 2016
fe96b92
Merge pull request #467 from glennrfisher/master
aemaeth-me Mar 15, 2016
653cf8c
Merge pull request #457 from CraigSiemens/master
aemaeth-me Mar 15, 2016
33b383c
Merge pull request #446 from kandelvijaya/patch-2
aemaeth-me Mar 15, 2016
2a5b70f
Merge pull request #443 from kandelvijaya/patch-1
aemaeth-me Mar 15, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
language: objective-c
script: "xcodebuild test -workspace SwiftyJSON.xcworkspace -scheme \"SwiftyJSON iOS\" -destination \"platform=iOS Simulator,name=iPhone 5\""

osx_image: xcode7.1
xcode_sdk: iphonesimulator9.0

script: 'sh scripts/ci.sh'

47 changes: 47 additions & 0 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,27 @@
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
04294C581BE5A9DE00D0397E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A82A1C4719D94E86009A653D /* SwiftyJSON.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = E4D7CCE81B9465A700EE7221;
remoteInfo = "SwiftyJSON watchOS";
};
04294C5A1BE5A9DE00D0397E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A82A1C4719D94E86009A653D /* SwiftyJSON.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 7236B4F61BAC14150020529B;
remoteInfo = "SwiftyJSON tvOS";
};
04294C5C1BE5A9DE00D0397E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A82A1C4719D94E86009A653D /* SwiftyJSON.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A8580F741BCF5C5B00DA927B;
remoteInfo = "SwiftyJSON tvOS Tests";
};
A8BF45AA1B871E100066C032 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A82A1C4719D94E86009A653D /* SwiftyJSON.xcodeproj */;
Expand Down Expand Up @@ -60,6 +81,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
04294C501BE5A9DE00D0397E /* Playground.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Playground.playground; sourceTree = "<group>"; };
A82A1C1919D926B8009A653D /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
A82A1C1D19D926B8009A653D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A82A1C1E19D926B8009A653D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -85,6 +107,7 @@
A82A1C1019D926B8009A653D = {
isa = PBXGroup;
children = (
04294C501BE5A9DE00D0397E /* Playground.playground */,
A82A1C4719D94E86009A653D /* SwiftyJSON.xcodeproj */,
A82A1C1B19D926B8009A653D /* Example */,
A82A1C1A19D926B8009A653D /* Products */,
Expand Down Expand Up @@ -128,6 +151,9 @@
A8BF45AD1B871E100066C032 /* SwiftyJSON iOS Tests.xctest */,
A8BF45AF1B871E100066C032 /* SwiftyJSON.framework */,
A8BF45B11B871E100066C032 /* SwiftyJSON OSX Tests.xctest */,
04294C591BE5A9DE00D0397E /* SwiftyJSON.framework */,
04294C5B1BE5A9DE00D0397E /* SwiftyJSON.framework */,
04294C5D1BE5A9DE00D0397E /* SwiftyJSON tvOS Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -193,6 +219,27 @@
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
04294C591BE5A9DE00D0397E /* SwiftyJSON.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = SwiftyJSON.framework;
remoteRef = 04294C581BE5A9DE00D0397E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
04294C5B1BE5A9DE00D0397E /* SwiftyJSON.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = SwiftyJSON.framework;
remoteRef = 04294C5A1BE5A9DE00D0397E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
04294C5D1BE5A9DE00D0397E /* SwiftyJSON tvOS Tests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = "SwiftyJSON tvOS Tests.xctest";
remoteRef = 04294C5C1BE5A9DE00D0397E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
A8BF45AB1B871E100066C032 /* SwiftyJSON.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
Expand Down
4 changes: 2 additions & 2 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ViewController: UITableViewController {
cell.textLabel?.text = "\(row)"
cell.detailTextLabel?.text = self.json.arrayValue.description
case .Dictionary:
let key: AnyObject = self.json.dictionaryValue.keys.array[row]
let key: AnyObject = Array(self.json.dictionaryValue.keys)[row]
let value = self.json[key as! String]
cell.textLabel?.text = "\(key)"
cell.detailTextLabel?.text = value.description
Expand Down Expand Up @@ -83,7 +83,7 @@ class ViewController: UITableViewController {
case .Array:
nextJson = self.json[row]
case .Dictionary where row < self.json.dictionaryValue.count:
let key = self.json.dictionaryValue.keys.array[row]
let key = Array(self.json.dictionaryValue.keys)[row]
if let value = self.json.dictionary?[key] {
nextJson = value
}
Expand Down
3 changes: 3 additions & 0 deletions Example/Playground.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//: Playground - noun: a place where people can play

import SwiftyJSON
4 changes: 4 additions & 0 deletions Example/Playground.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<timeline fileName='timeline.xctimeline'/>
</playground>
6 changes: 6 additions & 0 deletions Example/Playground.playground/timeline.xctimeline
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Timeline
version = "3.0">
<TimelineItems>
</TimelineItems>
</Timeline>
Empty file added Package.swift
Empty file.
49 changes: 33 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#SwiftyJSON [中文介绍](http://tangplin.github.io/swiftyjson/)

[![Travis CI](https://travis-ci.org/SwiftyJSON/SwiftyJSON.svg?branch=master)](https://travis-ci.org/SwiftyJSON/SwiftyJSON)

SwiftyJSON makes it easy to deal with JSON data in Swift.

1. [Why is the typical JSON handling in Swift NOT good](#why-is-the-typical-json-handling-in-swift-not-good)
Expand All @@ -26,7 +28,7 @@ The code would look like this:

```swift

if let statusesArray = try NSJSONSerialization.JSONObjectWithData(data, options: .AllowFragments) as? [[String: AnyObject]],
if let statusesArray = try? NSJSONSerialization.JSONObjectWithData(data, options: .AllowFragments) as? [[String: AnyObject]],
let user = statusesArray[0]["user"] as? [String: AnyObject],
let username = user["name"] as? String {
// Finally we got the username
Expand Down Expand Up @@ -75,7 +77,7 @@ if let userName = json[999999]["wrong_key"]["wrong_name"].string {

## Requirements

- iOS 7.0+ / Mac OS X 10.9+
- iOS 7.0+ / OS X 10.9+
- Xcode 7

##Integration
Expand All @@ -98,6 +100,22 @@ You can use [Carthage](https://github.com/Carthage/Carthage) to install `SwiftyJ
github "SwiftyJSON/SwiftyJSON"
```

####Swift Package Manager
You can use [The Swift Package Manager](https://swift.org/package-manager) to install `SwiftyJSON` by adding the proper description to your `Package.swift` file:
```swift
import PackageDescription

let package = Package(
name: "YOUR_PROJECT_NAME",
targets: [],
dependencies: [
.Package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", versions: "2.3.3" ..< Version.max)
]
)
```

Note that the [Swift Package Manager](https://swift.org/package-manager) is still in early design and development, for more infomation checkout its [GitHub Page](https://github.com/apple/swift-package-manager)

####Manually (iOS 7+, OS X 10.9+)

To use this library in your project manually you may:
Expand Down Expand Up @@ -161,7 +179,7 @@ for (key,subJson):(String, JSON) in json {
```swift
//If json is .Array
//The `index` is 0..<json.count's string value
for (key,subJson):(String, JSON) in json {
for (index,subJson):(String, JSON) in json {
//Do something you want
}
```
Expand Down Expand Up @@ -296,13 +314,13 @@ if let data = json.rawData() {
if let string = json.rawString() {
//Do something you want
}

```
####Existance
```swift
//shows you whether value specified in JSON or not
if json["name"].isExists()
```
```

####Literal convertibles
For more info about literal convertibles: [Swift Literal Convertibles](http://nshipster.com/swift-literal-convertible/)
```swift
Expand Down Expand Up @@ -360,16 +378,15 @@ json[path] = "that"

SwiftyJSON nicely wraps the result of the Alamofire JSON response handler:
```swift
Alamofire.request(.GET, url, parameters: parameters)
.responseJSON { (req, res, json, error) in
if(error != nil) {
NSLog("Error: \(error)")
print(req)
print(res)
}
else {
NSLog("Success: \(url)")
var json = JSON(json!)
Alamofire.request(.GET, url).validate().responseJSON { response in
switch response.result {
case .Success:
if let value = response.result.value {
let json = JSON(value)
print("JSON: \(json)")
}
case .Failure(let error):
print(error)
}
}
}
```
4 changes: 4 additions & 0 deletions Source/Info-tvOS.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
</dict>
</plist>
Loading