Dev Helpers
← Back

Flatten nested bins with their coordinates

Flatten nested bins with their coordinates using SQLite JSON functions.

Open this example in the interactive library

Source code

SELECT bin.key AS shelf, item.key AS slot,item.value AS part FROM json_each('[["A","B"],["C"]]') AS bin JOIN json_each(bin.value) AS item ORDER BY shelf,slot;

Sample output

[
  {
    "shelf": 0,
    "slot": 0,
    "part": "A"
  },
  {
    "shelf": 0,
    "slot": 1,
    "part": "B"
  },
  {
    "shelf": 1,
    "slot": 0,
    "part": "C"
  }
]