if i have simple json with
{
"age":29,
"messages":["msg 1","msg 2","msg 3"],
"name":"mkyong"
}
i use this code
public class JacksonExample {
public static void main(String[] args) {
ObjectMapper mapper = new ObjectMapper();
try {
// read from file, convert it to user class
User user = mapper.readValue(new File("c:\\user.json"), User.class);
// display to console
System.out.println(user);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
and get, one object. but what if i have
{
"age":29,
"messages":["msg 1","msg 2","msg 3"],
"name":"alice"
}
{
"age":18,
"messages":["msg 4","msg 5","msg 6"],
"name":"bob"
}
how can i get all objects from one json file and add their to list? sorry for my bad english