Using Datastax Java Driver to query a row as a JSON

后端 未结 1 822
滥情空心
滥情空心 2020-12-11 19:17

I am trying to use the datastax java driver and retrieve the row as a JSON.

I do the classic SELECT JSON * from myTable WHERE id=1 and this returns a J

相关标签:
1条回答
  • 2020-12-11 19:53

    As noted in the the Cassandra documentation:

    The results for SELECT JSON will only include a single column named [json]. This column will contain the same JSON-encoded map representation of a row that is used for INSERT JSON.

    In order to access the JSON value of the returned row, you need to use one of the getString methods defined on the Row class to get the value of this column either by index or by name:

    Row row = resultSet.one();
    String json1 = row.getString(0);
    String json2 = row.getString("[json]");
    
    0 讨论(0)
提交回复
热议问题