Reputation: 369
I have a table
CREATE TABLE table_a
(
id bigint NOT NULL,
name json,
CONSTRAINT table_a_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE table_a
OWNER TO postgres;
Data in the table:
1;"{"ru":"Название","en":"Name"}"
2;"{"ru":"Название","en":"Name"}"
When I trying select the name
SELECT id, name->'en'::text as name from table_a;
have next results:
1;""Name""
2;""Name""
How I can select data without quotes?
Thanks!
Upvotes: 0
Views: 261
Reputation: 28541
The ->
operator returns JSON
. Try using ->>
operator - it returns varchar
. Something like:
SELECT id, name->>'en'::text as name from table_a;
Upvotes: 4