Reputation: 31
I am completely don't know Json. Now i am working in Android project. I know how to use ArrayList. I have Json file inside of my Asset folder in my Android Project.
So, now i need How to parse this file from assets folder and how to store it to ArrayList.
Upvotes: 0
Views: 5433
Reputation: 614
String json="Your Json";
JSONObject resultJson = new JSONObject(json);
JSONArray value = resultJson.getJSONArray(<Pass Your JsonOject Key here>);
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < value.length(); i++)
{
JSONObject qstnArray = value.getJSONObject(i);
list.add(qstnArray.getString("question"));
}
Upvotes: 4