postgresql - How to remove {} and [] from json column postgresSQL -


i have column in postgressql json data type. until today there not row contained {} or [].

however, start see {} , [] due new implementation. want remove it.

example: following table looks like. json json data type

 id |       json        ----+------------------   | {"st":[{"state": "tx", "value":"0.02"}, {"state": "ca", "value":"0.2" ... ----+------------------  b  | {"st":[{"state": "tx", "value":"0.32"}, {"state": "ca", "value":"0.47" ... ----+------------------  d  | {} ----+------------------  e  | [] 

where want following:

 id |       json        ----+------------------   | {"st":[{"state": "tx", "value":"0.02"}, {"state": "ca", "value":"0.2" ... ----+------------------  b  | {"st":[{"state": "tx", "value":"0.32"}, {"state": "ca", "value":"0.47" ... 

how should able ?

i have writen following query:

select * tablea json::text <> '[]'::text  

where able filter empty elements starts {}. still seeing [].

very easy, select rows don't contain values:

select * tablea json :: text not in ('{}', '[]') 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -