SQLPro icon indicating copy to clipboard operation
SQLPro copied to clipboard

Pretty Print of JSON field changes order

Open halindrome opened this issue 1 year ago • 2 comments

Describe the bug If a field has contents that are "JSON" then the program will offer to pretty print the contents. However, when you do this, it will reorder the contents. In general, pretty printing should not change the order of the information.

To Reproduce Steps to reproduce the behavior:

  1. Add a row to a table that includes a column with JSON. Ensure the JSON is complex enough that it has a lot of keys with nested values.
  2. Look at the row.
  3. Select the column contents such that it appears in the popup detail modal.
  4. Select JSON for the highlight.
  5. Select Pretty Print

Expected behavior The original order should be maintained.

Screenshots

Sure - here are some:

CleanShot 2024-06-11 at 12 01 01

CleanShot 2024-06-11 at 12 01 18

Environment details (please complete the following information):

  • MacBook
  • OS: MacOS 14.4.1
  • SQLPro app Version SQL Pro Studio 2024.31 (Build 111098)
  • Installation source:Setapp
  • Target database server MariaDB

halindrome avatar Jun 11 '24 17:06 halindrome

Hmmm, I'm investigating this. The overall problem is that the JSON format itself states that the key order does not matter, so lots of api's for dealing with json also spec that the order is not guaranteed. That said, I am still looking into this to see what I can come up with.

hankinsoft avatar Jun 12 '24 12:06 hankinsoft

Understood. One idea - there is the concept of 'canonical JSON' (https://www.rfc-editor.org/rfc/rfc8785). Many of the popular libraries for pretty printing know about canonical JSON. If you use that, then at least it will render the same way every time.

halindrome avatar Jun 12 '24 19:06 halindrome

I've just submitted 2024.63 to Setapp which should resolve this. It generally takes about ~24 hours or so for a Setapp build to become available.

hankinsoft avatar Jul 31 '24 13:07 hankinsoft

Thanks for the update!

On Jul 31, 2024 at 8:30:28 AM, Kyle Hankinson @.***> wrote:

I've just submitted 2024.63 to Setapp which should resolve this. It generally takes about ~24 hours or so for a Setapp build to become available.

— Reply to this email directly, view it on GitHub https://github.com/hankinsoft/SQLPro/issues/991#issuecomment-2260532161, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7D4DZLQICIFUAIVLAL7LZPDRHJAVCNFSM6AAAAABJEXV4TCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRQGUZTEMJWGE . You are receiving this because you authored the thread.Message ID: @.***>

-- Shane McCarron @.***

halindrome avatar Jul 31 '24 14:07 halindrome

This should now be available. If you get the chance, please give it a try and let me know if that sorts things for you.

hankinsoft avatar Aug 01 '24 13:08 hankinsoft

It looks great - here is an example from a live system where very long fields now pretty print in the correct order

On Aug 1, 2024 at 8:13:32 AM, Kyle Hankinson @.***> wrote:

This should now be available. If you get the chance, please give it a try and let me know if that sorts things for you.

— Reply to this email directly, view it on GitHub https://github.com/hankinsoft/SQLPro/issues/991#issuecomment-2263010652, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAD7D4GEFDAWTN2Y54AZJ4DZPIX7ZAVCNFSM6AAAAABJEXV4TCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRTGAYTANRVGI . You are receiving this because you authored the thread.Message ID: @.***>

-- Shane McCarron @.***

halindrome avatar Aug 01 '24 13:08 halindrome

Great! I'm going to go ahead and close the issue. If you happen to get a chance, could you please consider leaving a rating/review on the Setapp store for SQLPro? As an independent developer, they help me out a ton.

hankinsoft avatar Aug 01 '24 14:08 hankinsoft