Array of objects in JSON
See original GitHub issueDescription
I need the beautified version not to start an array and object on the same line. This is for code folding with codemirror which only has one folding button per line. It defaults to folding the object but my intent was to fold the entire array. An annoying workaround is to enter a new line manually before folding. The current version looks prettier so I would like it to be an option rather than the default.
Input
The code looked like this before beautification:
{"stuff":[{"thing":"other thing"},{"thing":"other thing"}]}
Expected Output
The code should have looked like this after beautification:
{
"stuff": [
{
"thing": "other thing"
}, {
"thing": "other thing"
}
]
}
Actual Output
The code actually looked like this after beautification:
{
"stuff": [{
"thing": "other thing"
}, {
"thing": "other thing"
}]
}
Steps to Reproduce
I used indent_size: 2 as the only option. Can be reproduced on http://jsbeautifier.org/ I’m using js-beautify 1.7.5 from npm.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
JSON Array Literals
Arrays in JSON are almost the same as arrays in JavaScript. In JSON, array values must be of type string, number, object, array,...
Read more >JSON Array Structure
A JSON array contains zero, one, or more ordered elements, separated by a comma. The JSON array is surrounded by square brackets [...
Read more >JSON Array
JSON array represents ordered list of values. JSON array can store multiple values. It can store string, number, boolean or object in JSON...
Read more >Use a JSON array with objects with javascript
I have a function that will get a JSON array with objects. In the function I will be able to loop through the...
Read more >JSON Array - Multi-dimensional Array in JSON
JSON array can store string , number , boolean , object or other array inside JSON array. In JSON array, values must be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Does anyone expect this issue to ever get fixed? It’s the ONE issue I have with js-beautify, unfortunately.
@stevekanter-arcticleaf Nothing has changed. This project currently has very few contributors, so issues remain unfixed. If you’d like to take a swing at fixing this issue, come to the gitter channel and lets talk about what you’d need to do to make this happen.