JsonFormatter 0.1.0
Source: https://github.com/thomasmey/JsonFormatter.git
Announcement: Initial Plugin Central release
Requires Java 8?
Requires jEdit ? probably very old version
Required third-party applications: jakarta.json:jakarta.json-api:2.0.0, org.glassfish;jakarta.json:2.0.0
Description: Utility to pretty print JSON
not sure about license for this plugin because of above third party dependencies and their licenses.
Hello Thomas,
this doesn't seem ready to release yet:
- no license info
- it should be integrated with the beauty plugin
And it only formats selection, not the whole buffer. Is this intended?
yes. I think it should be possible to add another if to try to format the whole buffer if there's no selection
textArea.setSelectedText(s, baos.toString()) is deprecated. Specify an encoding
My bad, it's not deprecated: it's just wrong. JsonWriter will choose utf-8 encoding. ByteArrayOutputStream.toString() will use whatever your platform has for default encoding.
So, you should give JsonWriter a StringWriter to avoid this problem and the useless encoding/decoding from bytes.
Last edit: Eric Le Lay 2021-05-16
In fact the Beauty plugin already has json pretty printing.
What enhancement does your plugin provide?
Hi,
how to use that mode? The plugin only seems to tell me: "Error: can't beatify this buffer because I don't know how to handle this mode".
wow! you first need to configure the plugin to use the json beautifer for json mode, to make it work... this is really a bad UX!
Oh, good idea! It shouldn't be hard to adjust the code to detect the mode and apply the appropriate formatter if one is available.
Actually, this looks like an oversight in Beauty, the default json formatter isn't set in the Beauty properties file like the rest of the built-in formatters, so it needs to be set manually at the moment.
maybe it's also a good idea to mention that the Beatuy plugin supports JSON formatting somewhere in the plugins description, because currently this is not "findable" by the Plugin-Manager, search for "json" brings up only JSLint plugin...