title: Get all Cassandra query result in JSON format Using Java API
body: <p>Using query <code>select JSON * from table_name</code> in <em>cqlsh</em> I can get results in JSON format. I want to do the same using <em>Datastax</em> Java API.</p>
  
  <pre><code>StringBuilder sb = new StringBuilder("SELECT json * FROM ").append("JavaTest.data");
  String query = sb.toString();
  ResultSet rs = session.execute(query);
  List&lt;Row&gt; rows = rs.all();
  String q1 = rows.toString();
  System.out.println(q1);
  </code></pre>
  
  <p>But the result is :</p>
  
  <pre><code>[  
     Row   [  
        {  
           "id":1,
           "time":"12",
           "value":"SALAM"
        }
     ],
     Row   [  
        {  
           "id":2,
           "time":" 89",
           "value":" BYE"
        }
     ],
     Row   [  
        {  
           "id":3,
           "time":" 897",
           "value":" HelloWorld"
        }
     ]
  ]
  </code></pre>
  
  <p>that it is not in the correct <code>JSON</code> format. I know I can get the <code>JSON</code> of a row but in that way, I should use a loop to get all results in <code>JSON</code> format. Searching in <code>JAVA API</code> Docs I couldn't find any solution for this!</p>