Visualise newlines in long json strings?
We are filling our API docs in Swagger format which is basically a large JSON file.
Sometimes I need to write really much text into some "description" fields. It can contain many lines of text with formatting and other stuff.
JSON requires all line breaks to be escaped as \n. Which results into that all long strings with line breaks display as extremely long single-line string.
Just try to open this json in PHPStorm (WebStorm or other IDE): https://pastebin.com/SUVNbf1m
Look at how ugly it shows up in IDE: https://recordit.co/uBf7ntOuKf
It would be really cool if the IDE could display newlines in JSON as real newlines.
Even simple line-wrapping function would make my life easier but I can't find such setting.
Any ideas how to deal with it? Maybe there are some neat plugins for this (I searched but no luck)?
Please sign in to leave a comment.
Can't find anything to address this. You can submit this to our tracker at https://youtrack.jetbrains.com/newIssue
@Ilya
What about using a Soft Wraps functionality? Just use Search field in Settings/Preferences to have it enabled by default or all files. Switching it on/off for current file can be done via "View | Active Editor" menu (or gutter context menu).
Andriy Bazanov
Thanks a lot! It works. Enabled "Soft-wrap files" option and added json into the list.
Dmitry Tronin
Good note, I'll create a ticket now
Also i18n support needs to make all messages into JSON file. It is very hard to work without line wrapping.
BTW: soft-wrap doesn't help because it doesn't wrap line on a \n char, but only on the end of window.