Estou tentando recuperar dados de um arquivo Json, utilizando a API Json -simple, porem não estou conseguindo ler os valores, pois estão em um array.
esse é o arquivo json:
{
"devmovies":
{
"filme":
[
{
"id":1,
"titulo":"Os Arquivos JSON ",
"ano":1998,
"resumo":"A história dos arquivos muito leves",
"generos":["Ação","Sci-fi","Drama"],
"elenco":["Gillian Triggerson","David Markupovny"]
},
{
"id":2,
"titulo":"Sexta-feira 13: JSON vive",
"ano":1986,
"generos":["Ação","Horror"],
"elenco":["Ann Labelvalue Pair", "Jennifer Json", "John Java"]
}
]
}
}
Lendo o arquivo
JSONObject obJson = new JSONObject();
JSONParser parse = new JSONParser();
JSONArray array = new JSONArray();
try {
obJson = (JSONObject) parse.parse(new FileReader(arqJson));
//System.out.println(obJson.toJSONString());
array.addAll(obJson.values());
for (int i = 1; i < array.size(); i++) {
JSONObject json = (JSONObject)array.get(i);
System.out.println(json.toString());
}
} catch (FileNotFoundException ex) {
Logger.getLogger(Json_Model.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException | ParseException ex) {
Logger.getLogger(Json_Model.class.getName()).log(Level.SEVERE, null, ex);
}
}