我正在使用json-simple
。如果我有一个JSON,如:
[
{"id":"1","name":"...","description":"...","dtStart":"2012-03-27 03:00:00","dtEnd":"2012-03-28 03:00:00","activities":""},
{"id":"1","name":"...","description":"...","dtStart":"2012-03-27 03:00:00","dtEnd":"2012-03-28 03:00:00","activities":""},{"id":"1","name":"...","description":"...","dtStart":"2012-03-27 03:00:00","dtEnd":"2012-03-28 03:00:00","activities":""},
{"id":"1","name":"...","description":"...","dtStart":"2012-03-27 03:00:00","dtEnd":"2012-03-28 03:00:00","activities":""}
]
我如何迭代它?
答案 0 :(得分:0)
您展示的示例属于JSONArray,因为它位于[
和]
之间。
您应该像其他任何java Array
一样遍历它。
答案 1 :(得分:0)
这将创建一个包含3个地图的列表。
for (Object o : (List)parser.parse(json)){
Map m = (Map)o;
//handle map
}