Tuesday, October 28, 2014

Working with JSON!

It turned out that my entire issue yesterday (Android warning about "is INTERNET permission allowed?") was just that the page wasn't returning the data I needed. It turns out that I was using incorrect language codes, and the page didn't exist. It also turns out that it was returning a JSON array, which I can now access using the line:

 [CODE]translation1 = "English: " + readJsonFromUrl("https://glosbe.com/gapi/translate?from=eng&dest=eng&format=json&phrase=" + phrase + "&pretty=true").getJSONArray("tuc").get(0).toString();[/CODE]

This line will return the array that contains the phrase. I'm still working on exactly finding the translated phrase, but from here, it shouldn't be too hard to do!

1 comment: