Objectmapper: Parse JSON Array

Created on 10 Dec 2016  路  1Comment  路  Source: tristanhimmelman/ObjectMapper

Hi
How to parse json array of strings like "[\"one\", \"two\", \"three\", \"four\", \"five\"]" ?
this is a root json string array without any key...
so how can i implement Mapping method without any key?

 class Cities: Mappable {    
    var array: Array<String>?

    init() {

    }

    required init?(map: Map) {

    }

    // Mappable
    func mapping(map: Map) {

        array    <- map[""]
    }
}

Most helpful comment

You can use the following:

let array = Mapper<Object>().mapArray(JSONString: json)

>All comments

You can use the following:

let array = Mapper<Object>().mapArray(JSONString: json)
Was this page helpful?
0 / 5 - 0 ratings