美文网首页
iOS ObjectMapper

iOS ObjectMapper

作者: 不知所谓的所谓 | 来源:发表于2019-06-14 17:35 被阅读0次

    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"]

        }

    }

    相关文章

      网友评论

          本文标题:iOS ObjectMapper

          本文链接:https://www.haomeiwen.com/subject/gdgpfctx.html