wellsjo / JSON-Splora

GUI app for editing, visualizing, and manipulating JSON data
MIT License
1.86k stars 60 forks source link

Comments removed on paste #24

Closed MaanooAk closed 7 years ago

MaanooAk commented 7 years ago

On paste the formatInput() which recreates the Json from the parsed data, so the comments are lost because there are ignored from the parser.

Possible solution: just remove the formatInput() on the paste untill a proper format is implemented.

wellsjo commented 7 years ago

I think we should keep formatting on-paste, I'm going to label this as a bug instead. The issue is using JSON.stringify instead of a proper formatter. I tried using js-beautify before, but I don't like the way it formats arrays horizontally. Perhaps there is a better beautifier that handles arrays well?

MaanooAk commented 7 years ago

Perhaps there is a better beautifier that handles arrays well?

When inside the array if there is a object then they are formated like the menu.js

EDIT: And also there is non, they all use this format (and I personally prefer it)

vpillinger commented 7 years ago

This should be easy to make a menu option that allows the user to select between different formatters. Do you think that would be worth it? The majority of the work (on the menu side) for doing this has already been completed with adding options to change the Theme.

wellsjo commented 7 years ago

@vpillinger I like that idea...would it make sense to hide the formatter being used, but allow people to configure it with settings? For example, a setting might be arrays displayed vertically. If that option is set, use JSON.stringify. Otherwise expose options for js-beautify? Or do you think people would appreciate choosing their beautifier?

vpillinger commented 7 years ago

The problem with hiding the formatter is that there are other differences between the two formatters, so changing "vertical arrays" option would end up with many not obvious side effects. I think that in the long run we want to only use js-beautify and just provide interface to change the style options. If vertical array formatting is popular enough, then someone can contribute that option to js-beautify. If that happens then we can remove the JSON.Stringify option entirely.

wellsjo commented 7 years ago

True, I'm down to go with js-beautify and make it configurable