CREATE OR REPLACE FUNCTION jsonb_scalar_cat(data jsonb) RETURNS jsonb LANGUAGE plv8 AS $$ plv8.elog(NOTICE, 'arg = ' + JSON.stringify(data)); return data; $$; SELECT jsonb_scalar_cat(to_jsonb('asd'::TEXT)); NOTICE: arg = "asd" jsonb_scalar_cat ------------------ "asd" (1 row) SELECT jsonb_scalar_cat(to_jsonb(19450509::INT)); NOTICE: arg = 19450509 jsonb_scalar_cat ------------------ 19450509 (1 row) SELECT jsonb_scalar_cat(to_jsonb(false::BOOL)); NOTICE: arg = false jsonb_scalar_cat ------------------ false (1 row) SELECT jsonb_scalar_cat('{"key":[null, true, false, 19450509, "string"]}'::JSONB); NOTICE: arg = {"key":[null,true,false,19450509,"string"]} jsonb_scalar_cat -------------------------------------------------- {"key": [null, true, false, 19450509, "string"]} (1 row) SELECT jsonb_scalar_cat('{"key":true}'::JSONB); NOTICE: arg = {"key":true} jsonb_scalar_cat ------------------ {"key": true} (1 row) SELECT jsonb_scalar_cat('{"key":"true"}'::JSONB); NOTICE: arg = {"key":"true"} jsonb_scalar_cat ------------------ {"key": "true"} (1 row) SELECT jsonb_scalar_cat('{"key":19450509}'::JSONB); NOTICE: arg = {"key":19450509} jsonb_scalar_cat ------------------- {"key": 19450509} (1 row) SELECT jsonb_scalar_cat('{"key":null}'::JSONB); NOTICE: arg = {"key":null} jsonb_scalar_cat ------------------ {"key": null} (1 row) --SELECT jsonb_scalar_cat('null'::TEXT::JSONB);