使用Datastax Java驱动程序以JSON查询行 [英] Using Datastax Java Driver to query a row as a JSON
问题描述
我正在尝试使用datastax Java驱动程序并将该行作为JSON检索.
I am trying to use the datastax java driver and retrieve the row as a JSON.
我做经典
SELECT JSON * from myTable WHERE id=1
,它将在CQL上返回Json格式的字符串.
I do the classic
SELECT JSON * from myTable WHERE id=1
and this returns a Json formatted string on CQL.
例如{ "uuid" : "12324567-...." }
这有效.
现在,当我尝试使用Java驱动程序做同样的事情时,我使用(在scala中)
Now when, I try to do the same use the Java driver, I use (in scala)
val resultSet = session.execute(queryString)
我使用"resultSet.one()"
从此结果集中选择一行.
这有我需要的字符串,但是我该如何挑选呢?
I pick up one row from this result set using: "resultSet.one()"
.
This has the string I need, but how do I pick this up?
实验:resultSet.one().getColumnDefinitions.toString
打印:Columns[ [json] (varchar) ]
实验:resultSet.one().toString()
打印:Row[{"uuid": "3ce19e07-2280-4b31-9475-992bda608e70"}]
<-我需要的字符串
Experiment: resultSet.one().toString()
Prints: Row[{"uuid": "3ce19e07-2280-4b31-9475-992bda608e70"}]
<- String I need
如何在不尝试拆分上面的字符串的情况下,选择一个代表程序中JSON的简单字符串?
How do I pick up a simple string that represents the JSON in my program, without trying to split the strings above ?