JSON field view
已回答
Hi,
I'm working with JSON fields in Postgres, and was wondering if there was an option to visualise them in a more readable multi-line format than the default datable cells (without having to copy/paste in a separate formatter). I've been looking around but could not find anything.
Thanks a lot,
Julien
请先登录再写评论。
lint option would be very nice!
@Julien
Could you specify database type of your object column?
In case a column is varchar or similar, you can invoke Edit As Language action from context menu:
For json data type row value is formatted automatically:
That would be wonderful but that is not what I see. When I select "Edit As"-->JSON nothing happens. No linting or formating of any kind. I can copy it to a JSON it validates and formats perfectly. Are you working on Apple or Windows? Windows 7 here and no such luck.
Also - I don't want to have edit just to lint it. I just need to view it.
@ Derek Anderson
I'm working on Windows 7 Pro SP1.
Could you provide sample DDL to reproduce the issue?
In case you want only view your data you can simply double-click on the desired cell. If you're aware of the cell value modification, you can set up read-only connection.
Hi Vasily and thanks for answering! The column is of type jsonb in PostgreSQL. It is indeed coloured automatically when I double click, but not formatted as everything stays on a single line. (I see that the dataset that you use seems to be a bit different in the sense that the values in the database already have line breaks and indentation. Mine are raw, unformatted json).
The quickest way I found to get formatting was: click a cell and use 'Shift + Enter' to edit/view in maximized mode, then use Code > Reformat code (or the keyboard shortcut) and select OK. The contents gets formatted and indented on several lines. However this is a bit tedious because not only do I have to do this this for every row, but when I leave the cell I get a popup saying "Cannot apply changes" if I'm in a read-only situation (for example, query results), that I have to dismiss with OK.
I created a usability issue https://youtrack.jetbrains.com/issue/DBE-6670 you can follow.
Thanks!