When I create a .json
file in PyCharm and put in some JSON, I'm expecting it to format it as per the format shown under File
>
Settings
>
Editor
>
Code Style
>
JSON
.
But instead, my code stays as it is - e.g. more than one JSON key value pair on the same line, like this:
{"just a test": "does this work","this should format": "but it doesn't"}
How can I make it so that when I open a .json
file with PyCharm, it's nicely formatted?
I have checked that .json
files are associated in the editor -> file types dialogue, and the editor tab correctly has the JSON icon, so PyCharm knows it's a JSON file.
Is there a key combination I have to hit to get it to format prettily or something?
Formatting. You can format your JSON document using Ctrl+Shift+I or Format Document from the context menu.
Reading From JSON Python has a built-in package called json, which can be used to work with JSON data. It's done by using the JSON module, which provides us with a lot of methods which among loads() and load() methods are gonna help us to read the JSON file.
Ah, it doesn't auto-format it. If I paste in non-formatted JSON, it stays non-formatted. But if I press alt + cmd + L on Mac, Ctrl + Alt + L on windows, it formats it nicely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With