0

Hi friends how to handle the Single JSON Array, I am having a data class which contain set and getURL method. the simple json array is:

"tril" [
         "http://www.youtube.com/watch?v=hsTOC-wD-mk&feature=g-logo"
         "http://www.youtube.com/watch?v=cHhZwvdRR5c&feature=related"
         "http://www.youtube.com/watch?v=l4QWxw655z0&feature=related"
       ]

My code is:

JSONArray trailerArray = innerJson.getJSONArray(Constant.tril);
for(int i = 0; i < trailerArray.length(); i++) {
    String videoUrl = Constant.VIDEO_URL+trailerArray.getString(i);
    similarData.setMov_trail(videoUrl);
}

similar data is my data class, i am not able to get all the three videos. i am only getting the last video url how to handle this.

1 Answer 1

2

The format of the JSON array is not correct, it should be:

{
    "tril" :
    [
         "http://www.youtube.com/watch?v=hsTOC-wD-mk&feature=g-logo",
         "http://www.youtube.com/watch?v=cHhZwvdRR5c&feature=related",
         "http://www.youtube.com/watch?v=l4QWxw655z0&feature=related",
    ]
}
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for editing do you have any solution for this how can i get the exact data
Where do you want to get them to?
I used data class for getting and setting the data. while setting the data it is storing only last url. i want to use only the first url.
so instead of the for loop, just call String videoUrl = Constant.VIDEO_URL+trailerArray.getString(0); similarData.setMov_trail(videoUrl);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.