Skip to content

Commit 0ccbc9b

Browse files
authored
Merge pull request #34 from jkingoliver/master
Fix header spacing in README to enable highlighting
2 parents 4c57d46 + cc47ffc commit 0ccbc9b

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#SwiftyJSON [中文介绍](http://tangplin.github.io/swiftyjson/)
1+
# SwiftyJSON [中文介绍](http://tangplin.github.io/swiftyjson/)
22

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

@@ -19,7 +19,7 @@ SwiftyJSON makes it easy to deal with JSON data in Swift.
1919
- [Literal convertibles](#literal-convertibles)
2020
1. [Work with Alamofire](#work-with-alamofire)
2121

22-
##Why is the typical JSON handling in Swift NOT good?
22+
## Why is the typical JSON handling in Swift NOT good?
2323
Swift is very strict about types. But although explicit typing is good for saving us from mistakes, it becomes painful when dealing with JSON and other areas that are, by nature, implicit about types.
2424

2525
Take the Twitter API for example. Say we want to retrieve a user's "name" value of some tweet in Swift (according to Twitter's API https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline).
@@ -80,9 +80,9 @@ if let userName = json[999999]["wrong_key"]["wrong_name"].string {
8080
- iOS 7.0+ / OS X 10.9+
8181
- Xcode 7
8282

83-
##Integration
83+
## Integration
8484

85-
####CocoaPods (iOS 8+, OS X 10.9+)
85+
#### CocoaPods (iOS 8+, OS X 10.9+)
8686
You can use [Cocoapods](http://cocoapods.org/) to install `SwiftyJSON`by adding it to your `Podfile`:
8787
```ruby
8888
platform :ios, '8.0'
@@ -94,13 +94,13 @@ end
9494
```
9595
Note that this requires CocoaPods version 36, and your iOS deployment target to be at least 8.0:
9696

97-
####Carthage (iOS 8+, OS X 10.9+)
97+
#### Carthage (iOS 8+, OS X 10.9+)
9898
You can use [Carthage](https://github.com/Carthage/Carthage) to install `SwiftyJSON` by adding it to your `Cartfile`:
9999
```
100100
github "SwiftyJSON/SwiftyJSON"
101101
```
102102

103-
####Swift Package Manager
103+
#### Swift Package Manager
104104
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:
105105
```swift
106106
import PackageDescription
@@ -116,7 +116,7 @@ let package = Package(
116116

117117
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)
118118

119-
####Manually (iOS 7+, OS X 10.9+)
119+
#### Manually (iOS 7+, OS X 10.9+)
120120

121121
To use this library in your project manually you may:
122122

@@ -125,7 +125,7 @@ To use this library in your project manually you may:
125125

126126
## Usage
127127

128-
####Initialization
128+
#### Initialization
129129
```swift
130130
import SwiftyJSON
131131
```
@@ -141,7 +141,7 @@ if let dataFromString = jsonString.dataUsingEncoding(NSUTF8StringEncoding, allow
141141
}
142142
```
143143

144-
####Subscript
144+
#### Subscript
145145
```swift
146146
//Getting a double from a JSON Array
147147
let name = json[0].double
@@ -168,7 +168,7 @@ let name = json[].string
168168
let keys:[SubscriptType] = [1,"list",2,"name"]
169169
let name = json[keys].string
170170
```
171-
####Loop
171+
#### Loop
172172
```swift
173173
//If json is .Dictionary
174174
for (key,subJson):(String, JSON) in json {
@@ -183,7 +183,7 @@ for (index,subJson):(String, JSON) in json {
183183
//Do something you want
184184
}
185185
```
186-
####Error
186+
#### Error
187187
Use a subscript to get/set a value in an Array or Dictionary
188188

189189
If the JSON is:
@@ -226,7 +226,7 @@ if let name = json["name"].string {
226226
}
227227
```
228228

229-
####Optional getter
229+
#### Optional getter
230230
```swift
231231
//NSNumber
232232
if let id = json["user"]["favourites_count"].number {
@@ -264,7 +264,7 @@ if let id = json["user"]["id"].int {
264264
}
265265
...
266266
```
267-
####Non-optional getter
267+
#### Non-optional getter
268268
Non-optional getter is named `xxxValue`
269269
```swift
270270
//If not a Number or nil, return 0
@@ -283,7 +283,7 @@ let list: Array<JSON> = json["list"].arrayValue
283283
let user: Dictionary<String, JSON> = json["user"].dictionaryValue
284284
```
285285

286-
####Setter
286+
#### Setter
287287
```swift
288288
json["name"] = JSON("new-name")
289289
json[0] = JSON(1)
@@ -296,7 +296,7 @@ json.arrayObject = [1,2,3,4]
296296
json.dictionary = ["name":"Jack", "age":25]
297297
```
298298

299-
####Raw object
299+
#### Raw object
300300
```swift
301301
let jsonObject: AnyObject = json.object
302302
```
@@ -315,13 +315,13 @@ if let string = json.rawString() {
315315
//Do something you want
316316
}
317317
```
318-
####Existance
318+
#### Existance
319319
```swift
320320
//shows you whether value specified in JSON or not
321321
if json["name"].isExists()
322322
```
323323

324-
####Literal convertibles
324+
#### Literal convertibles
325325
For more info about literal convertibles: [Swift Literal Convertibles](http://nshipster.com/swift-literal-convertible/)
326326
```swift
327327
//StringLiteralConvertible
@@ -374,7 +374,7 @@ json["list",3,"what"] = "that"
374374
let path = ["list",3,"what"]
375375
json[path] = "that"
376376
```
377-
##Work with Alamofire
377+
## Work with Alamofire
378378

379379
SwiftyJSON nicely wraps the result of the Alamofire JSON response handler:
380380
```swift

0 commit comments

Comments
 (0)