【发布时间】:2017-06-19 17:28:17
【问题描述】:
我有一个来自 php 的字符串,看起来一模一样:"[{"id":"0","noteText":"Noteeeeeeee","date":"1232131","author":"John","authorId":"1"},{"id":"1","noteText":"Noteeeeeeee","date":"1232131","author":"Rob","authorId":"1"}]"
然后在我的onCreate 中的mainActiviry.java 我到了这一点:
String json = allNotes;
//System.out.println("String to Json Array Stmt");
JsonParser parser = new JsonParser();
JsonElement notes = parser.parse(allNotes);
JsonArray notesArr = notes.getAsJsonArray();
我的目标是将 json 字符串解析为 json 对象数组,然后对其进行循环并将其提供给 ListView。问题是我无法到达那里,因为我无法遍历这个jsonArray。我的java知识太有限了,所以其他问题对我帮助不大。
有人可以帮忙吗?
附言我正在使用 gson
【问题讨论】:
标签: java php android json gson