I'm trying to grab the contents of an external web service which returns an array of users in JSON format, then convert the JSON response into an array of EclipseUser objects. The response from the web service wraps the array of users in an array labelled 'users'. I've done some research but can't seem to find an example that shows me how to grab the items in the user array, and then convert them to Objects.
{
users: [
{
id: 2,
name: "David Cook",
username: "david.cook",
password: "12345",
email: "[email protected]"
},
{
id: 5,
name: "Kieran Barnby",
username: "kieran.barnby",
password: "12345",
email: "[email protected]
}
]
}
I'm wondering how I would go about retrieving the JSON and then converting it to an array of objects. Here's the object class:
public class EclipseUser {
public int id;
public String name;
public String username;
public String password;
public String email;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}