public String toJson ( ) { logger . entering ( ) ; parseResults ( ) ; Gson gson = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) ; String json = gson . toJson ( this ) ; logger . exiting ( json ) ; return json ; }
This method generate the JSON string for the instance . GSON builder helps to build JSON string and it will exclude the static and transient variable during generation .