how to parse responseString using alamofire and SwiftyJson


how to parse responseString using alamofire and SwiftyJson



I'm trying to parse responseString according to
Swift 3 - How to get JSON Objects with Alamofire and SwiftyJSON and https://github.com/SwiftyJSON/SwiftyJSON and Swift: Handling JSON with Alamofire & SwiftyJSON



responeString:


{success:false, title:'Traffic Authentication Page',fail_msg:'Register/Unregister was failed',desc:''}



Mycode :


let url = "url"

HttpsRequest.manager.request(url,method:.get).responseString{
response in
if response.result.isSuccess{
self.respnseJson = JSON(response.result.value!)

print ("success : (self.respnseJson["success"])")

}



but this code returns null. my question is: how to parse the response as a "responseString" not "responseJSON"
and how should it be in my case?
thank you in advance.





That's really your "JSON"? Because it's missing doubles quotes around the keys ({success: => {"success":, etc. and there shouldn't be single quotes, but doubles quotes for the values. Is your JSON even valid?
– Larme
Jul 3 at 9:41



{success:


{"success":





the response string not in JSON Formatter, you can check your response format here, jsonformatter.curiousconcept.com
– Afsara
Jul 3 at 10:19





Yes that's what I get from server..Is there any way to parse this response???
– Sorena H A
Jul 3 at 10:22





There is always to parse a response. The question are: is the way stable, adaptable, viable in future? Is it a "hack" that could broke tomorrow? Etc. Clearly, that's not recommended. Can you contact the developers behind the API? Does it need another param to answers in JSON?
– Larme
Jul 3 at 10:42






Android version of This application has already been written and uses the optString function for parsing Is There any similar sample for Swift?
– Sorena H A
Jul 3 at 18:01









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

Display dokan vendor name on Woocommerce single product pages