Skip to content

Commit fa99d44

Browse files
committed
Update md
1 parent 3ccf03d commit fa99d44

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
---
44

5-
## [1.1.0](https://github.com/kakaopensource/KakaJSON/releases/tag/1.0.0) (2019-08-27)
5+
## [1.1.0](https://github.com/kakaopensource/KakaJSON/releases/tag/1.1.0) (2019-08-27)
66
- Remove locks in ConvertibleConfig
77
- Simplify apis
88
- Merged pull requests

KakaJSON/Convert/Convertible.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ public struct ConvertibleKJ_M<T: Convertible> {
167167
basePtr.pointee.kj_convert(from: json)
168168
}
169169

170+
/// JSONObject -> Model
171+
public func convert(from json: [NSString: Any]) {
172+
basePtr.pointee.kj_convert(from: json as [String: Any])
173+
}
174+
170175
/// JSONObject -> Model
171176
public func convert(from json: NSDictionary) {
172177
basePtr.pointee.kj_convert(from: json as! [String: Any])

KakaJSON/Global/Model.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ public func model(from json: [String: Any],
1919
return json.kj.model(type: type)
2020
}
2121

22+
public func model<M: Convertible>(from json: [NSString: Any],
23+
_ type: M.Type) -> M {
24+
return json.kj.model(type)
25+
}
26+
27+
public func model(from json: [NSString: Any],
28+
type: Convertible.Type) -> Convertible {
29+
return json.kj.model(type: type)
30+
}
31+
2232
public func model<M: Convertible>(from json: NSDictionary,
2333
_ type: M.Type) -> M? {
2434
return json.kj.model(type)

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ write(Person(), to: file)
174174
// read Person from file
175175
let person = read(Person.self, from: file)
176176

177-
XCTAssert(person.name == "Jack")
178-
XCTAssert(person.car?.name == "Bently")
179-
XCTAssert(person.car?.price == 106.666)
180-
XCTAssert(person.books?.count == 2)
181-
XCTAssert(person.dogs?.count == 2)
177+
XCTAssert(person?.name == "Jack")
178+
XCTAssert(person?.car?.name == "Bently")
179+
XCTAssert(person?.car?.price == 106.666)
180+
XCTAssert(person?.books?.count == 2)
181+
XCTAssert(person?.dogs?.count == 2)
182182

183183
/****************** Model Array ******************/
184184
struct Car: Convertible {
@@ -571,7 +571,7 @@ let json: [[String: Any]] = [
571571

572572

573573
let cars1 = json.kj.modelArray(Car.self)
574-
XCTAssert(cars1?[1].name == "Bently")
574+
XCTAssert(cars1[1].name == "Bently")
575575

576576
let cars2 = modelArray(from: json, Car.self)
577577

0 commit comments

Comments
 (0)