Two JSON arrays can be aligned by their integer indexes. An inner join will omit an unmatched tail.
Worked example
SELECT a.value AS label,b.value AS reading FROM json_each('["in","out"]') a JOIN json_each('[18,21]') b USING(key) ORDER BY a.key;Result
[
{
"label": "in",
"reading": 18
},
{
"label": "out",
"reading": 21
}
]Implementation notes
Joining on key rather than position requires a stable identifier on both sides. Aligning by index is correct only when the arrays share an ordering contract.
Try it yourself
Remove the last measurement and check whether the corresponding label disappears.
Open the SQL example →Editorial date November 16, 2026 · Published December 6, 2026