Swift Convert XML to JSON

6k Views Asked by At

Is it possible to get a JSON var from XML on swift? I already get xml values with alamofire and SWXMLHash with the below code, but requirements said I must convert it to JSON, is there a way to achieve this?

Alamofire.request(strURL, parameters: nil)
        .responseData { response in
            let xml = SWXMLHash.parse(response.result.value!)
            if let text=xml["NewDataSet"]["Table"][0]["Book"].element?.text{
                print(text)

            }
    }
0

There are 0 best solutions below