hankinsoft / SQLPro

SQLPro bug & features tracking.
104 stars 27 forks source link

Pretty Print of JSON field changes order #991

Closed halindrome closed 2 months ago

halindrome commented 3 months ago

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):

hankinsoft commented 3 months ago

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.

halindrome commented 3 months ago

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.

hankinsoft commented 2 months ago

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.

halindrome commented 2 months ago

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 @.***

hankinsoft commented 2 months ago

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.

halindrome commented 2 months ago

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 @.***

hankinsoft commented 2 months ago

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.