Closed Nekokonab closed 5 years ago
you can use rxswift Observable.combine to get two json, then map to one json, then produce new one object.
What you did:
map JSON , create one object from JSON data
What you expected:
I want to MAP 2 JSONs , create one Object instead
What you got:
- Cant find a way to Map 2nd JSON to existing object which created from 1st JSON
- Cant find a way to Map 1st + 2nd JSON = and produce new one object
try this struct monster : Mappable { var name: String? var skill : String? var ability: [String]? init?(map: Map) { mapping(map: map) }
mutating func mapping(map: Map) { name <- map["name"] skill <- map["skill"] ability <- map["ability"] }
}
Your JSON dictionary:
First JSON { "name": "A", "skill": "B" }
Second JSON { "name" : nil "skill" : nil "ability" : [x , y , z , q ] }
What you did:
map JSON , create one object from JSON data
What you expected:
I want to MAP 2 JSONs , create one Object instead
What you got:
1) Cant find a way to Map 2nd JSON to existing object which created from 1st JSON 2) Cant find a way to Map 1st + 2nd JSON = and produce new one object