Herramientas de usuario

Herramientas del sitio


informatica:base_de_datos:postgresql:postgresql_json

¡Esta es una revisión vieja del documento!


PostgreSQL JSON

Probar si un JSON valido

<code postgresql> CREATE OR REPLACE FUNCTION f_is_json(_txt text)

RETURNS bool
LANGUAGE plpgsql IMMUTABLE STRICT AS

$func$ BEGIN

 RETURN _txt::json IS NOT NULL;

EXCEPTION

 WHEN SQLSTATE '22P02' THEN  -- invalid_text_representation
    RETURN false;

END $func$;

COMMENT ON FUNCTION f_is_json(text) IS 'Test if input text is valid JSON. Returns true, false, or NULL on NULL input.' </cpde>

informatica/base_de_datos/postgresql/postgresql_json.1770855608.txt.gz · Última modificación: 2026/02/12 00:20 por admin