Taking it a step further to provide a clear input table context and extremely varied input JSON structures:
PIVOT (
WITH RECURSIVE json_recursive AS (
SELECT
tbl.row_num,
key,
value,
json_type(value) as type
FROM (
SELECT 1 as row_num, '[{"a": 1, "b": {"c": 2, "d": 3}}, {"x": "test"}]' as val
UNION ALL
SELECT 2 as row_num, '{"r": 10000}' as val
) as tbl,
json_each(tbl.val)
UNION ALL
SELECT
parent.row_num,
child.key,
child.value,
json_type(child.value)
FROM json_recursive parent, json_each(parent.value) child
WHERE parent.type IN ('OBJECT', 'ARRAY')
)
SELECT row_num, key, value FROM json_recursive
WHERE type NOT IN ('OBJECT', 'ARRAY')
) ON key USING any_value(value);