1. Json(dictionary) -> Object
headerData = userInfoModel(JSON: json1.dictionaryObject ?? [:])
2. Json(Array) -> Objcet
listData = Mapper<listModel>().mapArray(JSONArray: json2.arrayObject as! [[String : Any]])
3.Create Model
import ObjectMapper
class userInfoModel:Mappable{
var username =""
var nick =""
var image =""
var avatar =""
requiredinit?(map:Map) {
}
funcmapping(map:Map) {
username<- map["username"]
nick<- map["nick"]
image<- map["image"]
avatar<- map["avatar"]
}
}
网友评论