Reputation:
I want to extract a JSON property from a JSON document. Let's simplify my example as following:
create table a(a text);
insert into a(a) select '{"name":"Kevin"}'::json -> 'name';
Now the table a
has a value "Kevin"
instead of Kevin
. Do I really have to manually extract the quotes?
I am using PostgreSQL v10.1.
Upvotes: 11
Views: 12116
Reputation:
The JSON operator ->
returns a JSON value. That's why it's quoted. If you want a plain text, use the operator that returns a text value: ->>
select '{"name":"Kevin"}'::json ->> 'name';
Upvotes: 41