I'm currently making a bible verse app for android, and the problem I am having might be common, but I find it difficult to implement since I'm a beginner.
How will I get each information in a string from the json data sampled below ?
{
"book": "1 John",
"chapters": [{
"chapter": "1",
"verses": [{
"1": "That which was from the beginning, which we have heard, which we have seen with our eyes, which we have looked upon, and our hands have handled, of the Word of life;"
}, {
"2": "(For the life was manifested, and we have seen it, and bear witness, and shew unto you that eternal life, which was with the Father, and was manifested unto us;)"
}]
}]
If I were to get each data so that I can use it as a string or a list, should I use a code like the following ? How can I change the code so that it can get the data from the json ? I would love to hear from you!
JSONObject obj = new JSONObject(script);
JSONArray chapters = obj.getJSONArray("chapters");
ArrayList < HashMap < String, String >> formList = new ArrayList < HashMap < String, String >> ();
HashMap < String, String > m_li;
for (int i = 0; i < chapters.length(); i++) {
JSONObject jo_inside = chapters.getJSONObject(i);
String formula_value = jo_inside.getString("chapters");
String url_value = jo_inside.getString("verse");
}