jsonb column text_results contains values in the following form : {'Name' : 'john doe' , 'id' : '123'}
On querying
Select text_results->>'Name' as Name from user_master
or
Select json_extract_path_text(text_results::json,'Name') as name from user_master
it always return None without any error even though values are present.
Need help with rectifying the error or any other way of extracting values from json column in POSTGRESQL.
Thanks in advance!
CodePudding user response:
Your query works as expected provided that JSON syntax is correct using double quotes. Here is an illustration.
with user_master(text_results) as
(
values ('{"Name": "john doe", "id": 123}'::jsonb)
)
select text_results->>'Name' as Name from user_master;
-- john doe