Postgresql JSON has key
json, postgresql, postgresql-9.3, sql
Solution
Problem solved. It was barely easy.
SELECT (customer_data->>'frameMenuData'->>'frameElement' IS NULL) AS has_frame,
Problem
I'm trying to understand the way the `Postgresql` is dealing with `JSON`. I've declared a two-columns table and I'd like to create a new View to get some boolean values. So far, I've been able to get the value as text but what I'd like to get is whether the field is defined or not. For example, if the `JSON` has the key `frameMenuData.frameElement`, it should print `has_frame` to true. ``` SELECT customer_data->>'frameMenuData'->>'frameElement' AS has_frame, FROM simple_list WHERE TRUE AND guid='AAAA'; ``` The above code gives me the content of that row. I need to know if `customer_data->>'frameMenuData'->>'frameElement'` is defined or not. How could I achieve that ? Thanks for your help.