문제

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.

도움이 되었습니까?

해결책

Problem solved. It was barely easy.

SELECT (customer_data->>'frameMenuData'->>'frameElement' IS NULL) AS has_frame,
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top