-
Notifications
You must be signed in to change notification settings - Fork 0
JSON Formatter
Rahul Raveendran edited this page Feb 8, 2017
·
1 revision
This class can format your JSON input (String/JSONObject/JSONArray) and return a String or colored HTML version of the same.
new JsonFormatter.Builder().build().format(json);
new JsonFormatter.Builder()
.setOutputFormat(JsonFormatter.HTML)
.build()
.format(json);
The library is provided with a default color theme which kind of look like that of Json Parser Online. The developer can change the color theme using the Builder class's methods.
Here is an example that changes the color of keys in the JSON.
new JsonFormatter.Builder()
.setOutputFormat(JsonFormatter.HTML)
.setKeyColor("#00ff00")
.build()
.format(json);
Note: The color theme works only for the HTML output.