У меня есть данные, подобные ниже
id | customer | region | circle
----------------------------------
1 | airtel | tn | c1
2 | reliance | ap | c2
Я ожидаю вывода json, как показано ниже, используя PostgreSQL
JSON
[
{"id":"1_airtel","parent":"#","text":"airtel"},
{"id":"1_airtel_tn","parent":"1_airtel","text":"tn"},
{"id":"1_airtel_tn_c1","parent":"1_airtel_tn","text":"c1"},
{"id":"2_reliance","parent":"#","text":"reliance"},
{"id":"2_reliance_ap","parent":"2_reliance","text":"ap"},
{"id":"2_reliance_ap_c2","parent":"2_reliance_ap","text":"c2"}
]