JSON merge in postgresql

From: Arup Rakshit <aruprakshit(at)rocketmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: JSON merge in postgresql
Date: 2015-03-27 18:00:54
Message-ID: 2074711.SjZpPot3r7@linux-wzza.aruprakshit
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a simple table having column `data` which is a JSON type. Sample data I took from -- http://schinckel.net/2014/05/25/querying-json-in-postgres/

[arup(at)pg_food_mgmt (master)]$ rails db
psql (9.2.7)
Type "help" for help.

pg_foo_development=# SELECT * FROM json_test;
id | data
----+--------------------------------------
1 | {}
2 | {"a": 1}
3 | {"a": 2, "b": ["c", "d"]}
4 | {"a": 1, "b": {"c": "d", "e": true}}
5 | {"b": 2}
(5 rows)

Now suppose I want to update the record#1 and # 2 as {"a": 12} and {"a": 2, "b": ["c", "d"]} .. What is the way to update this ?

--
================
Regards,
Arup Rakshit
================
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.

--Brian Kernighan

Browse pgsql-general by date

  From Date Subject
Next Message Day, David 2015-03-27 18:01:29 Re: segmentation fault postgres 9.3.5 core dump perlu related ?
Previous Message Adrian Klaver 2015-03-27 17:47:54 Re: Building JSON objects