-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FeatureRequest] format array items each on new line #80
Comments
I was about to suggest exactly this, I'd love to see this feature implemented. This is not only something that makes it visually pleasant to see, but also enables quicker diff comparisons between two json files if each item is in a new line after applying a Format and Sort. |
Hi, I usually favor the original compact format, especially for numbers. I often store numerical data in JSON (3D vectors, index arrays, coordinates lists, ...) and things like this are more convenient (especially with large numerical arrays): "position": [0, 0, 10.5],
"vertices": [-1.0, 0, 1.15, -3.212, 10, 0, -34.1] What I'd suggest is to limit these arrays to a maximum configurable line length (or max number of items per line), so they don't grow indefinitely. For example, in my own C++ JSON formatter, I write up to 10 numerical elements per line, and then add a newline to cotinue for the next 10. For arrays of strings, unless they are very short, I'd say I prefer one per line. |
Such option would indeed be nice |
I hope I can have time to figure this out, but it is really a difficult feature. Because when it comes an array, algorithm cannot know how long it will be, or is there some functions/classes in it (or is it a pure number/variable array). It can only know the result after result is produced. In my current algorithm, it only see 1 or 2 words ahead, and can only look back (already produced result), so "put a pure number array in one line" is not easy to implement with current algorithm. I'll keep this issue open, but I don't think it will be resolved in short time. |
@sunjw I think the request has been confused. The original request is simply to add an option within the plugin settings to split each item in a JSON array to a new line, rather than keeping them all on the same line. The suggestion of making the algorithm "smart" in identifying e.g. a pure number array was, I think, more of a "would be nice" element of the feature, but not a requirement. If the simpler option could be implemented first, it would be more than sufficient for my, and I think most users', needs. |
@knw257 I'll see what I can do. |
Add option to format array items on new lines.
Array:
["a", "b", "c"]
should be formatted like this:
The text was updated successfully, but these errors were encountered: