public static String toJsonAsString ( ) { logger . entering ( ) ; Gson gson = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) ; JsonObject configItem = new JsonObject ( ) ; for ( Entry < String , Map < String , String > > entry : ReporterConfigMetadata . getReporterMetaData ( ) . entrySet ( ) ) { Map < String , String > subMap = entry . getValue ( ) ; for ( Entry < String , String > subEntry : subMap . entrySet ( ) ) { JsonObject configSubItem = new JsonObject ( ) ; configSubItem . addProperty ( subEntry . getKey ( ) , subEntry . getValue ( ) ) ; configItem . add ( entry . getKey ( ) , configSubItem ) ; } } String json = gson . toJson ( configItem ) ; logger . exiting ( json ) ; return json ; }
This method will generate JSON string representation of the all items in current ReportConfigMetadata .