Return results of a sql query as JSON in oracle 12c
12cR2 (available in the Oracle Cloud) supports this natively. SQL> select JSON_ARRAY(EMPLOYEE_ID, FIRST_NAME,LAST_NAME) from HR.EMPLOYEES; JSON_ARRAY(EMPLOYEE_ID,FIRST_NAME,LAST_NAME) ——————————————————————————– [100,”Steven”,”King”] [101,”Neena”,”Kochhar”] or SQL> select JSON_OBJECT(‘ID’ is EMPLOYEE_ID , ‘FirstName’ is FIRST_NAME,’LastName’ is LAST_NAME) from HR.EMPLOYEES; JSON_OBJECT(‘ID’ISEMPLOYEE_ID,’FIRSTNAME’ISFIRST_NAME,’LASTNAME’ISLAST_NAME) —————————————————————————- {“ID”:100,”FirstName”:”Steven”,”LastName”:”King”} {“ID”:101,”FirstName”:”Neena”,”LastName”:”Kochhar”}