postgresql - Postgres: How to change the case of JSON keys? -


my address column being stored json using format:

{ "street1": "800 smithe st", "street2": null, "city": "vancouver", "region": null, "state": "bc", "zip": "v6z 2e1" }

how can change column values camel case / lowercase, appear this?

{ "street1": "800 smithe st", "street2": null, "city": "vancouver", "region": null, "state": "bc", "zip": "v6z 2e1" }

with j(j) ( values ($$   {     "street1": "800 smithe st",     "street2": null,     "city": "vancouver",     "region": null,     "state": "bc",     "zip": "v6z 2e1"   } $$::jsonb)) select json_object_agg(lower(key), value) j, jsonb_each(j) je group j;                                                        json_object_agg                                                        -----------------------------------------------------------------------------------------------------------------------------  { "zip" : "v6z 2e1", "city" : "vancouver", "state" : "bc", "region" : null, "street1" : "800 smithe st", "street2" : null } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -