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

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -