Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON Formatter for Eclipse

I want to format the JSON files in my eclipse on save file action, based on number of spaces that i can configure. I tried using JSON Editor Plugin but it gave me null pointer exception on saving.

Error on saving with Json Editor Plugin Then i tried JSON Tools plugin and it worked but it used a tab for formatting the lines. Is there any hack that i can do with plugin jar to configure and change TAB to 4 spaces? Are better json formatter available for eclipse?

like image 630
pseudoCoder Avatar asked Jun 02 '15 09:06

pseudoCoder


People also ask

How do I beautify JSON in eclipse?

Goto Window > Preferences > JSON > JSON Files > Editor. Then under the Formatting section, toggle the "Indent using spaces" radio. You might want to adjust your "indentation size" too, e.g. to 2, 3, or 4 spaces.

Does Eclipse support JSON?

JSON Editor Plugin Unfortunately, Eclipse doesn't contain a decent JSON editor by default. This plugin helps you with this shortcoming. With the JSON Editor, you can create and edit JSON files in a developer-friendly way.


2 Answers

Some other extensions adhere to the preference set for the general text editor.

If it doesn't clash with other settings you can try:

General -> Appearance -> Editors -> Text Editors

[x] Insert spaces for tabs

like image 52
Robert Fey Avatar answered Oct 15 '22 02:10

Robert Fey


Have you tried Json Tools for Eclipse? It is handy and lightweight Eclipse plugin. I have checked this right now and it works as you want - if there are TABs in a modified JSON file, they are changed to 4 spaces.

You can find it in Marketplace or install it using update site:

https://bitbucket.org/denmiroch/jsontools/src/default/JsonSite/
like image 37
l__j Avatar answered Oct 15 '22 01:10

l__j