I had problem close to this one (NOT actually not reverting the JSON expression), but in my case I was looking for the key-value inside a hierarchy, therefore it was a composition of -> and @> (maybe OP's original problem got simplified when posting).
On such a case, we must consider that (per postgres docs):
The field/element/path extraction operators return NULL, rather than failing, if the JSON input does not have the right structure to match the request; for example if no such key or array element exists.
For example, if one is looking for the key/value pair nested into some hierarchy, but part of that hierarchy doesn't exist, the expression will be NULL instead of false, and NOT NULL is NULL, not true.
A catch-all solution is to wrap the original expression in NOT COALESCE(<original expression>, false).
NOT?NOTsimply doesn't work. Using theattributes->>'City' <> 'Mesa'formulation also doesn't work.NOTworks pretty well.