Skip to content

Commit 81ad157

Browse files
committed
update doc
1 parent a41e26e commit 81ad157

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# TidyJSON
22

3-
TidyJSON is a neat and tidy JSON package run on all Swift platforms (Linux, iOS, OS X)
3+
TidyJSON is a neat and tidy JSON package run on all Swift platforms (Linux, iOS, OS X, tvOS, watchOS)
44

55
[![Build Status](https://travis-ci.org/benloong/TidyJSON.svg?branch=master)](https://travis-ci.org/benloong/TidyJSON)
66

77
## Goals
88
- [x] simple, neat and tidy json lib
99
- [x] safe static typed without `AnyObject`
10+
- [x] performance
1011
- [x] pure Swift, only dependent to builtin types
11-
- [x] compatible with all Swift platforms (Linux, iOS, OS X)
12+
- [x] compatible with all Swift platforms (Linux, iOS, OS X, tvOS, watchOS)
1213
- [x] concise usage
1314
- [x] boxing dict and array type for mutating data
1415
- [x] modify json via subscript operator
@@ -19,6 +20,9 @@ TidyJSON is a neat and tidy JSON package run on all Swift platforms (Linux, iOS,
1920
## Usage
2021

2122
### Literal Convertible
23+
24+
Literal value can be type safe converted to TidyJSON.JSON like this:
25+
2226
```swift
2327
let jsonFalse : JSON = false
2428
let jsonTrue : JSON = true
@@ -29,7 +33,10 @@ let jsonArray : JSON = [12, "string", false, nil, true, ["nested array", 12, 1.2
2933
let json : JSON = ["key":false, "key2":true, "key3":[1, "hello", 3, "world", ["key4":nil, "key5":12.03, "key6":12E-2, "key7": -12e-2]]]
3034
```
3135

32-
### Update value
36+
### Access value
37+
38+
Get and Set value via Subscripts:
39+
3340
```swift
3441
var json : JSON = []
3542
// []
@@ -64,21 +71,21 @@ json1["hello"] = false
6471
json1["world"] = true
6572
// {"hello":false, "world":true}
6673

74+
// remove a key
6775
json1["hello"] = nil
6876
// {"world":true}
6977

7078
json1["world"] = [1,2,3]
7179
// {"world":[1,2,3]}
7280
```
7381

74-
7582
### Parse from String
7683
```swift
7784
let json1 = JSON.parse("{\"key\" : false }")
7885
if let b = json1["key"].bool {
7986
print(b)
8087
}
81-
/* out
88+
/*
8289
false
8390
*/
8491

@@ -87,7 +94,7 @@ let json2 = JSON.parse("{\"key\" : [\" \\u0041334 \\n \\t \\\" \"]}")
8794
if let x = json2["key"][0].string {
8895
print(x)
8996
}
90-
/* out
97+
/*
9198
A334
9299
"
93100
*/
@@ -139,6 +146,12 @@ After install `XCTest`, run `sh run_test.sh`
139146

140147
## Integration
141148

149+
#### Carthage
150+
151+
To integrate TidyJSON into your Xcode project using Carthage, specify it in your Cartfile:
152+
153+
github "benloong/TidyJSON"
154+
142155
#### Swift Package Manager
143156

144157
Currently support Swift Package Manager to install TidyJSON by adding the proper description to your Package.swift file:

0 commit comments

Comments
 (0)