I\'m trying to retrieve JSON data from an external source for practice. I have gotten all the code in place but for some reason I get an error saying that the document is no
The value is being pass, but however null is also getting passed with it so use an if statement rather than using while like this..
if (myJSON != null) {
myJSON = bufferedReaderObject.readLine();
completeJSONdata += myJSON;
}
then convert in Gson like this..
Gson gson = new Gson();
deserializedContainerObject = gson.fromJson(completeJSONdata, DeserializedContainer.class);
write the getters and setters in DeserializedVariables
class
public String getMovieName() {
return movieName;
}
public void setMovieName(String movieName) {
this.movieName = movieName;
}
public Integer getMovieYear() {
return movieYear;
}
public void setMovieYear(Integer movieYear) {
this.movieYear = movieYear;
}
public Double getMovieRating() {
return movieRating;
}
public void setMovieRating(Double movieRating) {
this.movieRating = movieRating;
}
And now you can retrieve it in your onPostExecute()
like this..
@Override
protected void onPostExecute( DeserializedContainer result) {
mListener.onSuccess( result );
for (int i = 0; i