My json response contains not only strings, but also array of DTO. Object mapping is not happening in the right format.
{
\"
The below solved my issue :
In LoanDetailServiceClass,
func getLoanDetails(success: @escaping((_ loanDetailModel: LoanDetailModel?) -> ()),
failure: @escaping ((_ error:String) -> ())) {
// Define mappings
let postMapping: RKObjectMapping = RKObjectMapping(for: LoanDetailModel.self)
postMapping.addAttributeMappings(from: ["id","componentName"])
let dTOListMapping: RKObjectMapping = RKObjectMapping(for: DynamicTableDetailDTOList.self)
dTOListMapping.addAttributeMappings(from: ["fieldName",
"fieldType",
"label"])
postMapping.addRelationshipMapping(withSourceKeyPath: "DynamicTableDetailDTOList" ,
mapping: dTOListMapping)
// Define response decriptor
let statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClass.successful)
let resDescriptor = RKResponseDescriptor(mapping: postMapping, method: RKRequestMethod.GET, pathPattern: nil, keyPath: nil, statusCodes: statusCodes)
// Create object manager
let url = URL(string: baseURL)
let jsonPlaceholderManager = RKObjectManager(baseURL: url)
jsonPlaceholderManager?.addResponseDescriptor(resDescriptor)
RKObjectManager.setShared(jsonPlaceholderManager)
// Perform GET request
RKObjectManager.shared().getObjectsAtPath(appendedURL, parameters: nil, success: { (operation, mappingResult) -> Void in
let loanDetailModel: LoanDetailModel = mappingResult!.firstObject as! LoanDetailModel
success(loanDetailModel)
}) { (operation, error) -> Void in
failure((error?.localizedDescription)!)
}
}