Dev Helpers
← Back

Turn a dictionary into ordered key-value rows

Turn a dictionary into ordered key-value rows using SQLite JSON functions.

Open this example in the interactive library

Source code

SELECT key AS part,value AS stock FROM json_each('{"pad":3,"pen":5}') ORDER BY stock DESC;

Sample output

[
  {
    "part": "pen",
    "stock": 5
  },
  {
    "part": "pad",
    "stock": 3
  }
]