For a "deep" toString() there is an alternative to the JSON based answers (Jackson, GSON, etc.): ReflectionToStringBuilder from the Apache Commons Lang 3 library, with RecursiveToStringStyle or MultilineRecursiveToStringStyle. Code example:
System.out.println("My object: " + ReflectionToStringBuilder .toString(theObject, new RecursiveToStringStyle())); // or as "toString()" overrides @Override public String toString() { return ReflectionToStringBuilder .toString(this, new RecursiveToStringStyle()); } // or @Override public String toString() { return ReflectionToStringBuilder .toString(this, new MultilineRecursiveToStringStyle()); } Output examples:
// RecursiveToStringStyle Person@7f54[name=Stephen,age=29,smoker=false,job=Job@43cd2[title=Manager]] // MultilineRecursiveToStringStyle Person@7f54[ name=Stephen, age=29, smoker=false, job=Job@43cd2[ title=Manager ] ]