Postico icon indicating copy to clipboard operation
Postico copied to clipboard

[Feature request]: All things JSON...

Open daviestar opened this issue 6 years ago • 10 comments

Postico is great, it's sleek and fast! However I'm using Postgres JSONB functionality more and more, and it could really do with some TLC in this area. Here are some ideas I think could help improve the experience of using JSON in Postico:

  1. Pretty print by default when hovering over a JSONB field, and in the righthand pane.

  2. Currently when switching to Pretty Print in the righthand pane it considers this a mutation of the field and asks to Save Changes. I would suggest making this purely presentational to not risk mutating the field just for pretty previews.

  3. There's currently no way to preview pretty printed JSONB in the SQL Query tab, which makes it really tough to work with large JSON responses. A righthand pane, and pretty printed preview on hover would go a long way in this view.

  4. It would be great to have an option to toggle between the current 'rows' response view, and a purely JSON response view in the SQL Query tab. (Similar to https://github.com/jakob/Postico/issues/459)

Thanks for listening!

What software versions are you using?

Postico version: 1.3.4 (2642) macOS version: 10.13.5 PostgreSQL version: 9.6.6

daviestar avatar Jul 02 '18 10:07 daviestar

Hey @daviestar,

we have been working on some improvements regarding Postico JSON:

  • JSONB is autoformatted in the right sidebar
  • JSON/B copy special / formatting now supports numeric values and retains the order of keys
  • added copy special support for JSON lines format

It will be released with 1.5.18, in the meantime there is already a preview build available: https://eggerapps-downloads.s3.eu-west-1.amazonaws.com/postico-8121.zip

Any feedback or issues discovered are highly appreciated!

Best regards, Martin

martinjankoehler avatar May 20 '21 17:05 martinjankoehler

hi @martinjankoehler,

the pretty printing is only available in the righthand pane for regular tables, right? That is already good, but it doesn't cover my use case ...

I'm mainly looking for a better JSON view for queries results. Most of the queries I write for APIs return 1 row with 1 column containing a fairly complex JSON object. Currently I can barely debug these with postico. I either have to write different subqueries that returns the data without aggregating them into JSON objects, or I have to copy it into a text editor for pretty printing.

Ideally postico should have a query result mode specifically for large JSON objects (or XML). The view mode should have features like syntax highlighting and folding.

qwesda avatar May 20 '21 19:05 qwesda

I've got a small issue: right-click on a JSONB cell, and select Copy Cell clear the copy/paste buffer, but doesn't copy the actual JSONB.

doekman avatar May 25 '21 09:05 doekman

Thanks for your feedback @doekman, the Copy Cell issue should be fixed with this build: https://eggerapps-downloads.s3.eu-west-1.amazonaws.com/postico-8135.zip Please let us know if it also resolves the issue on your side.

martinjankoehler avatar May 25 '21 18:05 martinjankoehler

Thanks for your feedback @qwesda, this v2 build contains a preview of the JSON viewer for regular table cells and query result table cells: https://eggerapps-downloads.s3.eu-west-1.amazonaws.com/postico-8134.dmg

martinjankoehler avatar May 25 '21 18:05 martinjankoehler

@martinjankoehler This fixes the issue.

Also: this is a very welcome addition to Postico. I've also peeked at the JSON viewer in the v2 build. That also looks promising! I'm glad to see these improvements come to Postico.

doekman avatar May 26 '21 08:05 doekman

@martinjankoehler looks like a promising start! Two notes:

  • double clicking in results view doesn't do anything for JSON cells
  • the button on the side is good for discoverability, but a bit finicky for clicking, I would prefer double clicking anywhere on the cell to open the JSON viewer (if the viewer opens with everything selected, if invoked through double click, there wouldn't be a functional difference to the current behaviour)

qwesda avatar May 26 '21 08:05 qwesda

About JSON-validation: it's ultimately something Postgres would do, like it would with date and number validation. In the v2 beta I see there is validation in place, before data is saved. When I edit JSON in the JSON viewer (shouldn't it be called JSON editor?), and make a mistake, and press "Done", it all seems OK. When I press "[...]" to show the JSON viewer again, a yellow bar is shown with an error-message. NICE. I like it.

However: can you show this error-message before I close the popover? One way to do this might be, when you press "Done", and there is an error, don't close the popover just yet, and show the error. Press "Done" again, and the popover closes. So:

  1. edit JSON and make a mistake
  2. press "Done"
  3. error message is shown
  4. press "Done" again
  5. popover closes

While normally:

  1. edit JSON and it is correct JSON
  2. press "Done"
  3. popover closes

Other feedback: is there a way to open the JSON viewer with keyboard? When I select a row, pressing TAB cycles though the columns. When I have a enum typed column selected, the spacebar brings up the popup-menu. Is there a shortcut for this? And is it discoverable (like via the menu)?

Also: The "Discard changes" button in the JSON viewer seems to be disabled in some situation. Steps to reproduce:

  1. Make a change to the JSON via the JSON viewer
  2. The "Discard Changes" button is enabled (as expected)
  3. Press "Done"
  4. Show the JSON viewer again by pressing "[...]"
  5. The "Discard Changes" button is disabled (not as expected)

It's possible to press the "Discard Changes" button from the list-view, but since the JSON viewer is a view on the same data, I would expect the button to be enabled.

Thanks!

doekman avatar May 31 '21 15:05 doekman

We've now merged the JSON viewer in Postico 2.

@qwesda: As you requested, you can now just double click JSON cells to open the viewer. That was a good idea.

@doekman: We've addressed some of your suggestions. We removed the "Discard Changes" button in the popover, since it was confusing. We added a button to check the syntax before closing the popover.

There's currently no way to use the keyboard to open the JSON viewer, but that would be useful. We have to think about this.

jakob avatar Aug 24 '21 14:08 jakob

Hi - is there any way to configure Postico's JSON pretty printing to apply to Redshift's JSON column type, which for unknown reasons is called "super" instead of "json" or "jsonb"?

vergenzt avatar Jun 03 '22 15:06 vergenzt