title: Get jsonArray Using Native query entity manager
body: <p>I have an service class as below:</p>
  
  <pre><code>public class RulesService {
      @PersistenceContext
      private EntityManager em;
  
      public  JSONArray getReportingTableData(String Query) {
          List&lt;Object&gt; list = em.createNativeQuery(Query).getResultList();
  
          return /*convert the above list as json array**/;
      }
  }
  </code></pre>
  
  <p>So, if the query is "select col1 as name,col2 as agefrom table1" then my jsonArray should be</p>
  
  <pre><code>[{"name":"test","age":"24"},{"name":"test1","age":"26"}]
  </code></pre>
  
  <p>I don't want to use pojo or entity class here, because the query will get change dynamically and there are many number of tables here, so I don't want to create seperate java class for each table.That is the reason am trying to make it as a JSONArray.</p>
  
  <p>Can anyone please give me the right solution do it.</p>