This is the json string returned from a server. I am trying to Map it to a object mapper class and print values but I get the following error.
Error Domain=NSCocoaErrorDomain Code=3840 "No string key for value in object around character 1."
{'Status': False, 'updatedStatus': True, 'connectionStatus': True}
And following is my mapper class
public class Info: Mappable {
internal let kStatusKey: String = "Status"
internal let kConnectionStatusKey: String = "connectionStatus"
internal let kupdatedStatusKey: String = "updatedStatus"
// MARK: Properties
public var Status: String?
public var connectionStatus: String?
public var updatedStatus: String?
// MARK: ObjectMapper Initalizers
/**
Map a JSON object to this class using ObjectMapper
- parameter map: A mapping from ObjectMapper
*/
required public init?(_ map: Map){
}
/**
Map a JSON object to this class using ObjectMapper
- parameter map: A mapping from ObjectMapper
*/
public func mapping(map: Map) {
Status <- map[kStatusKey]
connectionStatus <- map[kConnectionStatusKey]
updatedStatus <- map[kUpdatedStatusKey]
}
}
I cannot change the string returned from the server, Is there any way I can fix my code. Any help will be appreciated. Thank you.
Your JSON should look like this:
{
"status": false,
"updatedStatus": true,
"connectionStatus": true
}
Update your mapper upon this.