I have table users with json column details.
users
details
I want to fetch all user records where details[\"email\"] is null or email key doesn\'t exist.
You need to use the ->> operator for that:
->>
select * from users where (details->>'email') is not null
Because the -> operator returns 'null'::json (and not sql NULL) if the key is exists but with a json null value.
->
'null'::json
NULL
http://sqlfiddle.com/#!15/76ec4/2