Skip to content

Commit

Permalink
Merge pull request #1079 from itruf/master
Browse files Browse the repository at this point in the history
ImmutableMappable init fix
  • Loading branch information
tristanhimmelman committed Mar 16, 2020
2 parents 19d499c + 73cb592 commit 8b69860
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Sources/Mappable.swift
Expand Up @@ -46,7 +46,7 @@ public protocol StaticMappable: BaseMappable {
static func objectForMapping(map: Map) -> BaseMappable?
}

public extension BaseMappable {
public extension Mappable {

/// Initializes object from a JSON String
init?(JSONString: String, context: MapContext? = nil) {
Expand All @@ -65,12 +65,15 @@ public extension BaseMappable {
return nil
}
}

}

public extension BaseMappable {

/// Returns the JSON Dictionary for the object
func toJSON() -> [String: Any] {
return Mapper().toJSON(self)
}

/// Returns the JSON String for the object
func toJSONString(prettyPrint: Bool = false) -> String? {
return Mapper().toJSONString(self, prettyPrint: prettyPrint)
Expand Down

0 comments on commit 8b69860

Please sign in to comment.