Open ChiriVulpes opened 6 years ago
https://github.com/TheAwesomeGem/BlockDropsTweaker/blob/master/src/main/java/net/theawesomegem/blockdropstweaker/common/blockconfig/ConfigurationHandler.java#L156-L169
This is the way I write JsonObjects to strings in my mod:
private static String getJsonString (final JsonObject json, final String indent) { try { final StringWriter stringWriter = new StringWriter(); final JsonWriter jsonWriter = new JsonWriter(stringWriter); jsonWriter.setLenient(true); jsonWriter.setIndent(indent == null ? "" : indent); Streams.write(json, jsonWriter); return stringWriter.toString(); } catch (final IOException e) { return null; } }
And then you just provide the method with the string it should indent with. Passing null or an empty string does minified JSON (like it is currently).
In the meantime, if you use Sublime Text, install the "JSON Reindent" package. Fix you right up. But I agree, it'd be nice to have this as the default.
https://github.com/TheAwesomeGem/BlockDropsTweaker/blob/master/src/main/java/net/theawesomegem/blockdropstweaker/common/blockconfig/ConfigurationHandler.java#L156-L169
This is the way I write JsonObjects to strings in my mod:
And then you just provide the method with the string it should indent with. Passing null or an empty string does minified JSON (like it is currently).