Closed krypt-lynx closed 4 years ago
Issue is not entirely correct, as I can see after some research.
It is possible to do Mapper<Book>().mapDictionary(JSONString: <...>)
, but in my case I need an universal solution because of abstractions.
It looks like BaseMappable protocol should be adopted in one way or another:
extension Array : BaseMappable where Element: BaseMappable {
// <...>
}
extension Dictionary : BaseMappable where Key == String, Value: BaseMappable {
// <...>
}
extension Set : BaseMappable where Element: BaseMappable {
// <...>
}
In current traversing implementation those extensions have no point: Dictionary works out of luck, other to cannot be processed.
Your JSON dictionary:
api link (it's public): https://openlibrary.org/api/books?bibkeys=ISBN:0451526538&format=json
Your model:
What you did:
What you expected:
Successful mapping
What you got:
Compile time error: Type 'Dictionary<String, Book>' does not conform to protocol 'BaseMappable'