Skip to content

Commit

Permalink
add init(JSONObject:Any)
Browse files Browse the repository at this point in the history
  • Loading branch information
leavez committed Nov 23, 2018
1 parent 4548ba7 commit ad1f464
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Sources/Mappable/Mappable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import Foundation

///
///
/// This is the protocol the models should be conformed with.
///
public protocol Mappable {
init(map: Mapper) throws
Expand All @@ -20,7 +19,14 @@ public protocol Mappable {
/// Conveint initializers for JSON
public extension Mappable {

/// Initializes object from a JSONObject
/// Initializes object from a JSON object
///
/// A JSON object could be Dictionary, Array or plain String/Number value. It could
/// be the result of JSONSerialization(jsonObject:options:).
public init(JSONObject: Any) throws {
let mapper = JSONMapper(JSON: JSONObject)
try self.init(map: mapper)
}
public init(JSONObject: [String: Any]) throws {
let mapper = JSONMapper(JSON: JSONObject)
try self.init(map: mapper)
Expand Down

0 comments on commit ad1f464

Please sign in to comment.