'JSON_EACH Columns

I have the following code

   SELECT 

 p1.json_data -> 'factSheet'->'fact_sheet' ->'cash_flow' AS Date

 FROM loan_applications AS l
 LEFT JOIN risk_scores AS p1
 ON l.id = p1.loan_application_id
 WHERE l.human_readable_id = 'XXX'

And get this ouput: {"21-01-11": 772.28, "21-01-12": 1210.28,...}

For my understanding, I should use json_each

 json_each(p1.json_data -> 'factSheet'->'fact_sheet' ->'cash_flow') AS Date

but that just gives me the following output:

(21-01-11,772.28)
(21-01-12,1210.28)
...
...

I basically want the Date in one column and the revenue in the other.

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source