如何将雪花响应变成JSON格式?
这是我正在开发的Spring Boot API的一部分。我正在查询雪花以使用这样的查询来获取一些数据:
select distinct OBJECT_CONSTRUCT(
'id', id,
'name', name,
'etc', etc
) as RESPONSE from ...
我获得了类似格式的字符串列表:
list:
0-> {'id':1, 'name':name, 'etc':etc}
1-> {'id':2, 'name':name, 'etc':etc}
2-> {'id':3, 'name':name, 'etc':etc}
...
我可以对API可以返回的单个JSONNODE响应获得此响应的最清洁方法?
This is part of a spring boot API I am developing. I am querying snowflake to get some data using a query like this:
select distinct OBJECT_CONSTRUCT(
'id', id,
'name', name,
'etc', etc
) as RESPONSE from ...
I am getting a a List of String which is formatted like this:
list:
0-> {'id':1, 'name':name, 'etc':etc}
1-> {'id':2, 'name':name, 'etc':etc}
2-> {'id':3, 'name':name, 'etc':etc}
...
What is the cleanest way that I can get this response to a single JsonNode response that the api can return?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原始语句,生产单个行 -
接下来,我们将使用
array_agg
将结果粘合到单个实体中。如果需要,可以根据需要通过
to_json
或parse_json
进一步转换结果。以下将提供字符串输出 -
以下将提供JSON输出 -
Original statement, producing individual rows -
Next we will use
ARRAY_AGG
, to get result clubbed into single entity.If required, the result can be further converted as needed via
TO_JSON
orPARSE_JSON
.Below will give string output -
Following will give JSON output -