title: Return results of a sql query as JSON in oracle 12c
body: <p><strong>Background</strong></p>
  
  <p>I need to fetch a few thousands rows from Oracle and convert them to JSON for use in SlickGrid. 
  Currently I am fetching the rows in PHP, converting it from ISO to UTF-8 with iconv and exporting to json with json_encode. The whole operation takes about 1 second on DB side and 5 seconds to generate JSON. It is way to long.</p>
  
  <p><strong>The question</strong></p>
  
  <p>I have read that Oracle 12c supports JSON, but I cannot find exactly what I need.</p>
  
  <p>Is there a way to return the result of a standard sql query in a json format?</p>
  
  <p>supposedly I would like to issue a query similar to this:</p>
  
  <pre><code>SELECT * from table AS JSON
  </code></pre>
  
  <p>and receive a valid json  similar to this: </p>
  
  <pre><code>[{"col1": "value1", "col2": 2}, {"col1": "valueOfRow2", "col2": 3}]
  </code></pre>
  
  <p>An important thing is that I need to have the unicode sequences escaped for me, as I use ISO-8859-2 charset on the client side, and JSON have to be in either UTF-8 or have the sequences escaped.</p>