Reputation: 23
I am not your complete package programmer / developer. Please go easy on me. In many cases its just a search term I am unfamiliar with.
I have this code:
"CustomFields": [
{"Name": "TextTest2","Content": ""},
{
"Name": "DealerNames",
"Content": ""
},
{
"Name": "PricingProducts",
"Content": ""
},
{
"Name": "Structure",
"Content": ""
},
That i would prefer written like this:
"CustomFields": [
{"Name": "TextTest2","Content": ""},
{"Name": "DealerNames","Content": ""},
{"Name": "PricingProducts","Content": ""},
{"Name": "Structure","Content": ""},
I am aware it is not the normal beautify / prettier structure but much of my inputs / outputs have thousands of key value pairs in JSON and all the additional spaces make the code hard to read.
I use VSCODE but any online formatter that has this option would be helpful.
If there is nothing just say so.
Upvotes: 1
Views: 1857
Reputation: 1
You can try this JSON formatter and restructure your code - https://toolbox.land/json-formatter
or you can configure prettier to do the same as well https://prettier.io/docs/en/configuration.html
Upvotes: -2
Reputation: 306
You might want to take a look at FracturedJson. It tries to make JSON readable by indenting, but keeping simple and short arrays/objects on a single line. That link takes you to the browser-based formatter, but if it looks like what you're looking for, there's a VSCode extension too. (Disclosure: I'm the author. It's open-source under the MIT license.)
Here's what your sample data looks like, formatted with the default settings:
{
"CustomFields": [
{ "Name": "TextTest2" , "Content": "" },
{ "Name": "DealerNames" , "Content": "" },
{ "Name": "PricingProducts", "Content": "" },
{ "Name": "Structure" , "Content": "" }
]
}
Upvotes: 3
Reputation: 712
You can use several online JSON formatters. For example JSON Formatter
In this you can select compact option in JSON template. Using this your JSON text will be formatted to:
{"CustomFields":[{"Name":"TextTest2","Content":""},{"Name":"DealerNames","Content":""},{"Name":"PricingProducts","Content":""},{"Name":"Structure","Content":""}]}
However, I am not sure that getting all the elements on new line is possible in any formatter.
Upvotes: 0