I'm trying to convert a list of objects into json but the values are the location in memory.
public class User {
private String name;
private int score;
public User(String name, int score){
this.name = name;
this.score = score;
}
User user1= new User("Luke", 50);
User user2 = new User("Ryan", 70);
List<User> list = Arrays.asList(user1, user2);
Gson gson = new Gson();
String json = gson.toJson(list);
System.out.println(list);
The last line is supposed to show my objects in json but instead i just get [User@579bb367, User@1de0aca6], why is this? thanks