As the code below:
public class Main {
public class innerPerson{
private String name;
public String getName(){
return name;
The "address" that you see printed is simply what your toString() method returns.
Disregarding the JSON marshaling for now In order for your code to work, you need to implement: equals(), hashCode() and toString() within your InnerPerson class. If you return the name property in toString(), that will become the key in your JSON representation.
But without proper implementations for equals() and hashCode(), you cannot make proper use of a HashMap.