为什么 json 箭头运算符在 postgres 中不起作用?
Why are json arrow operators not working in postgres?
我正在尝试从 json 类型的列中提取信息。这是我的查询:
SELECT column_name -> 'key_name' FROM table.
我收到以下错误消息,指的是箭头运算符:
No operator matches the given name and argument type(s). You might need to add explicit type casts.
如果我尝试 ->>
也是一样。
-- 编辑:这是完整的错误信息:
ERROR: operator does not exist: text -> unknown
LINE 1: SELECT candidate_owner_json -> 'ownerid' FROM candidate
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
SQL state: 42883
Character: 29
我试过这个并且有效:
SELECT json_array_elements(candidate_owner_json::json)->'ownerId' FROM ...
我正在尝试从 json 类型的列中提取信息。这是我的查询:
SELECT column_name -> 'key_name' FROM table.
我收到以下错误消息,指的是箭头运算符:
No operator matches the given name and argument type(s). You might need to add explicit type casts.
如果我尝试 ->>
也是一样。
-- 编辑:这是完整的错误信息:
ERROR: operator does not exist: text -> unknown
LINE 1: SELECT candidate_owner_json -> 'ownerid' FROM candidate
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
SQL state: 42883
Character: 29
我试过这个并且有效:
SELECT json_array_elements(candidate_owner_json::json)->'ownerId' FROM ...