postgresql - PSQL 仅返回来自 jsonb_each 的值
问题描述
我正在打电话jsonb_each_text
,它完全按照我的预期工作,给我回了这个:
select jsonb_each_text('{"text": "this is text", "text2": "this is text2", "f_id": "21"}') as line;
line
-------------------------
(f_id,21)
(text,"this is text")
(text2,"this is text2")
(3 rows)
我知道我可以通过这样做轻松地只返回密钥:
select jsonb_object_keys('{"text": "this is text", "text2": "this is text2", "f_id": "21"}') as line;
line
-------
f_id
text
text2
(3 rows)
有没有办法只能返回值?
因此,例如,我希望将其作为我的输出:
line
-------------------------
21
"this is text"
"this is text2"
这些值不需要是唯一的或任何东西。
我一直无法找到与jsonb_object_keys
for values only 的等价物。
解决方案
将其用作适当的集合返回函数:
select t.value
from jsonb_each_text('{"text": "this is text", "text2": "this is text2", "f_id": "21"}') as t(key, value);
推荐阅读
- c++11 - C ++ CRTP:如何使基类的一个(某些)函数成为派生类的朋友?
- regex - 提取文本文件行中的部分重复模式
- go - 如何在切片中分配动态类型
- r - purrr map2 说参数是不同的长度
- r - 用于创建自举假设检验的 r 函数
- python - 如何在熊猫数据框中读取 mongodb 导出的 Json
- jhipster - 错误!:弹性搜索问题 UnsatisfiedDependencyException:创建名称为“userService”的 bean 时出错
- java - 使用 Junit 生成多个单元测试
- python - 在 python 2.7 中构建、安装和运行 yoink
- java - 空白最终变量