3

I have json string like '{"ww":11}'

How can i get value 11 in pl/pgsql ?

I try:

json_var := '{"ww":11}'::json

json_var->ww;
json_var->"ww";
json_var.ww;

All of this failed.

Please help! Dmitry

2 Answers2

1

The json type is just text. The advantage of using it is syntax check. Just that.

Check this question

Community
  • 1
  • 1
Clodoaldo Neto
  • 118,695
  • 26
  • 233
  • 260
  • but in other pl* language json field are accessable. see this example https://github.com/tobyhede/postsql/blob/master/postsql.sql – seyed Jun 05 '13 at 07:02
0

you need to typecast it to Json in order to do that.

select '{"ww":11}'::json->'ww' as ww_value

returns ....

11

Virendra Patel
  • 441
  • 5
  • 5