Gson doesn't support serializing anonymous types.
See the duplicate linked by Sotirios Delimanolis. Note that the double brace initializer you were using effectively creates an anonymous subclass, which has some nasty side effects like creating new classes every time you use it, and breaking things like Gson.
It would work if you created a constructor like this:
class Ideone
{
public class Person {
public String Name;
public String Address;
public Person(String Name, String Address) {
this.Name = Name;
this.Address = Address;
}
}
public static void main (String[] args) throws java.lang.Exception
{
Person person = new Person("John", "London");
// System.out.println(person.Name);
Gson gson = new Gson();
String jsonPerson = gson.toJson(person);
}
}
As an aside, you should not name your fields with capital letters; begin classes with capital letters and fields with lowercase letters.
Have a look at the Google Java Style Guide for a good reference on naming conventions