Reputation: 83
I'm developing a Translator App on Menubar for MacBooks.
Problem:
I can't parse JSON results from Google Translate API.
Example JSON result:
{
"data": {
"translations": [
{
"translatedText": "Hello World"
}
]
}
}
Please help me!
Edit : Add my codes
http://imgim.com/ekranresmi2015-06-21112615.png
and i use SwiftHTTP for http requests. https://github.com/daltoniam/SwiftHTTP
Upvotes: 1
Views: 1277
Reputation: 83
I solved problem use SwiftyJSON :)
https://github.com/SwiftyJSON/SwiftyJSON
Upvotes: 1
Reputation: 8124
I hope according to your given screenshot of your code sample your JSON string is containeed within the str
variable. So solution would be something like as follows:
NSString *translatedText = str["data"]["translations"][0]["translatedText"];
I suggest you to read the following given tutorial link.
Upvotes: 1