Rookie Java question here: I have an ArrayList of values that store properties of my user object, like so:
{"users":["Bob", 35, "230 Elm Street", "bob@website.com"]}
My User Object:
public class User{
    private String name;
    private int age;
    private String address;
    private String email;
    //getters & setters
}
I need to map each of these values to their respective properties so that I can return a proper Key/Value JSON Object, like so:
["name": "Bob", "age": 35, "address": "230 Elm Street", "email": "bob@website.com"]
I'm a little confused on how to approach this; Do I need to use a Map to manually set each keywhile iterating through my list, something like...
for(User user : list){
    HashMap myMap = new HashMap();
    myMap.put("name", user.getName());
    myMap.setAge("age", user.getAge());
    //etc...
}
//Convert Map to JSON
return new JSONObject(myMap);
Or is it simpler than that? Thanks for the help!
 
     
     
     
     
    