- 1 minute read

There is a nice library that makes creating and reading Json objects fun: Google GSon. I use it in every class of mine to implement a toString() method. You can even use to to implement the clone() method (if you don't care about performance):

class VariableDefinition { public String toString() { Gson g = new Gson() g.toJson(this) } public VariableDefinition clone() { Gson g = new Gson() g.fromJson(g.toJson(this), VariableDefinition.class) } }

The reason why I'm adding a toString() method to every class is that the eclipse debugger uses this method to display complex objects nicely:


Comments