JSONExport
JSONExport copied to clipboard
Does not handle nest json objects
Nested Json Package Below
The issue is that it's converting json dictionary objects into strings, and not it's proper value.

"id": 16,
"user_id": 6,
"name": 4,
"med_gastro": "{'left': {'mvc': 0, 'effeciency_score': 0, 'exhaustion': [0, 0, 0]}, 'right': {'mvc': 0, 'effeciency_score': 0, 'exhaustion': [0, 0, 0]}}",
"lat_gastro": "{'left': {'mvc': 0, 'effeciency_score': 0, 'exhaustion': [0, 0, 0]}, 'right': {'mvc': 0, 'effeciency_score': 0, 'exhaustion': [0, 0, 0]}}",
"tib_anterior": "{'left': {'mvc': '13816.0', 'effeciency_score': 20.804231942965192, 'exhaustion': {'maxEffeciency': 10.16597510373444, 'subMaxEffeciency': 3.2009484291641965, 'minEffeciency': 86.63307646710136}, 'effeciency': 20.804231942965192}, 'right': {'mvc': '13816.0', 'effeciency_score': 0, 'exhaustion': [0, 0, 0]}}",
"peroneals": "{'left': {'mvc': 0, 'effeciency_score': 0, 'exhaustion': [0, 0, 0]}, 'right': {'mvc': 0, 'effeciency_score': 0, 'exhaustion': [0, 0, 0]}}"
}
Coded Oject
import Foundation
import ObjectMapper
class PlayerProfile : NSObject, NSCoding, Mappable{
var id : Int?
var latGastro : String?
var medGastro : String?
var name : Int?
var peroneals : String?
var tibAnterior : String?
var userId : Int?
class func newInstance(map: Map) -> Mappable?{
return PlayerProfile()
}
required init?(map: Map){}
private override init(){}
func mapping(map: Map)
{
id <- map["id"]
latGastro <- map["lat_gastro"]
medGastro <- map["med_gastro"]
name <- map["name"]
peroneals <- map["peroneals"]
tibAnterior <- map["tib_anterior"]
userId <- map["user_id"]
}
/**
* NSCoding required initializer.
* Fills the data from the passed decoder
*/
@objc required init(coder aDecoder: NSCoder)
{
id = aDecoder.decodeObject(forKey: "id") as? Int
latGastro = aDecoder.decodeObject(forKey: "lat_gastro") as? String
medGastro = aDecoder.decodeObject(forKey: "med_gastro") as? String
name = aDecoder.decodeObject(forKey: "name") as? Int
peroneals = aDecoder.decodeObject(forKey: "peroneals") as? String
tibAnterior = aDecoder.decodeObject(forKey: "tib_anterior") as? String
userId = aDecoder.decodeObject(forKey: "user_id") as? Int
}
/**
* NSCoding required method.
* Encodes mode properties into the decoder
*/
@objc func encode(with aCoder: NSCoder)
{
if id != nil{
aCoder.encode(id, forKey: "id")
}
if latGastro != nil{
aCoder.encode(latGastro, forKey: "lat_gastro")
}
if medGastro != nil{
aCoder.encode(medGastro, forKey: "med_gastro")
}
if name != nil{
aCoder.encode(name, forKey: "name")
}
if peroneals != nil{
aCoder.encode(peroneals, forKey: "peroneals")
}
if tibAnterior != nil{
aCoder.encode(tibAnterior, forKey: "tib_anterior")
}
if userId != nil{
aCoder.encode(userId, forKey: "user_id")
}
}
}