JSON merge in postgresql
JSON merge in postgresql
От:
Arup Rakshit <aruprakshit@rocketmail.com>
Дата:
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@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