I\'m trying to check if a key exists in a JSON sent as parameter in a PL/pgSQL function.
Here is the function.
CREATE FUNCTION sp_update_user(user_in
The "json_object_keys" function can be a solution.
You can select the result of a query that uses this function into a declared variable and then check if your variable is null. Here is an example:
DECLARE
test character varying;
BEGIN
SELECT a INTO test FROM json_object_keys(user_info) a WHERE a = 'lastname';
IF (test IS NOT NULL) THEN
--SUCESSS
ELSE
--FAIL
END IF;
END;