tristanhimmelman / AlamofireObjectMapper

An Alamofire extension which converts JSON response data into swift objects using ObjectMapper
MIT License
2.66k stars 476 forks source link

it's still working ????? i am working on this but always show some error i don't no why #321

Open exploitcrew opened 2 years ago

exploitcrew commented 2 years ago

func getUsers() { let URLSTring = "https://jsonplaceholder.typicode.com/posts" AF.request(URLSTring).responseJSON { response in if let JSON = response.data { let str = String(decoding: JSON, as: UTF8.self) //print(str)

        let result = Mapper<ArrayResponse<ResponseModel>>().map(JSONString: str)

        //self.userlist = Mapper<ResponseModel>().mapArray(JSONString: String(str))
        let responseModel = Mapper<ResponseModel>().mapArray(JSONString: "\(String(describing: response.data))")
        print(responseModel)

        //let JSONString = Mapper().toJSONString(responseModel, prettyPrint: true)

        // Convert JSON String to Model
        //let responseModel = Mapper<ResponseModel>().map(JSONString: str)

        // Create JSON String from Model

        //let JSONString = Mapper<ResponseModel>().map(JSONString: str)

        //let responseModel = Mapper<ResponseModel>().mapArray(JSONString: str)

    }

    //let users = Mapper<ResponseModel>().mapArray(JSONObject: data)

}

}