Kayshav.com
About Developer Oracle 19c Oracle 12c Technology Information Sitemap

Oracle JSON functions Updates
-- Oracle 19c: JSON functions Updates 

SELECT
   JSON_VALUE('{"a" : "2019-01-14T09:25:26.0075"}', '$.a' RETURNING TIMESTAMP
              ERROR ON ERROR
             )   date_timestamp,
   CAST(JSON_VALUE('{"a" : "2019-01-14T09:25:26.0075"}', '$.a' RETURNING TIMESTAMP 
                   ERROR ON ERROR
                  ) AS DATE)  date_value
FROM DUAL
;


-- IS JSON function => Returns True/False
-- First three rows are valid JSON

SELECT
 qt.ref_str
FROM (
 SELECT '{ "Automobile": "Ford" }'  ref_str  FROM DUAL UNION
 SELECT '{ ''Automobile'': ''Tesla'' }'   ref_str  FROM DUAL UNION
 SELECT '{ "isAnimal": "False" }'   ref_str  FROM DUAL UNION
 SELECT 'A Random String'  ref_str FROM DUAL UNION
 SELECT NULL  ref_str FROM DUAL
) qt
WHERE  qt.ref_str IS JSON
;

SELECT
 qt.ref_str
FROM (
 SELECT '{ "Automobile": "Ford" }'  ref_str  FROM DUAL UNION
 SELECT '{ ''Automobile'': ''Tesla'' }'   ref_str  FROM DUAL UNION
 SELECT '{ "isAnimal": "False" }'   ref_str  FROM DUAL UNION
 SELECT 'A Random String'  ref_str FROM DUAL UNION
 SELECT NULL  ref_str FROM DUAL
) qt
WHERE  qt.ref_str IS JSON STRICT            -- for STRICT JSON syntax 
;


SELECT
 qt.ref_str
FROM (
 SELECT '{ "Automobile": "Ford" }'  ref_str  FROM DUAL UNION
 SELECT '{ "Automobile": "Ford" }'  ref_str  FROM DUAL UNION
 SELECT '{ ''Automobile'': ''Tesla'' }'   ref_str  FROM DUAL UNION
 SELECT '{ "isAnimal": "False" }'   ref_str  FROM DUAL UNION
 SELECT 'A Random String'  ref_str FROM DUAL UNION
 SELECT NULL  ref_str FROM DUAL
) qt
WHERE  qt.ref_str IS JSON  WITH UNIQUE KEYS
;

SELECT
 qt.ref_str
FROM (
 SELECT '{ "Automobile": "Ford" }'  ref_str  FROM DUAL UNION
 SELECT '{ "Automobile": "Ford" }'  ref_str  FROM DUAL UNION
 SELECT '{ ''Automobile'': ''Tesla'' }'   ref_str  FROM DUAL UNION
 SELECT '{ "isAnimal": "False" }'   ref_str  FROM DUAL UNION
 SELECT 'A Random String'  ref_str FROM DUAL UNION
 SELECT NULL  ref_str FROM DUAL
) qt
WHERE  qt.ref_str IS JSON  WITHOUT UNIQUE KEYS
;


-- IS NOT JSON function => Returns True/False
-- Fourth row is not valid JSON

SELECT
 qt.ref_str
FROM (
 SELECT '{ "Automobile": "Ford" }'  ref_str  FROM DUAL UNION
 SELECT '{ ''Automobile'': ''Tesla'' }'   ref_str  FROM DUAL UNION
 SELECT '{ "isAnimal": "False" }'   ref_str  FROM DUAL UNION
 SELECT 'A Random String'  ref_str FROM DUAL UNION
 SELECT NULL  ref_str FROM DUAL
) qt
WHERE  qt.ref_str IS NOT JSON
;



  Oracle 19c Index

  Lower Versions   11g Index   12c Index

Oracle registered trademark of Oracle Corporation.

Last Revised On: January 27th, 2021

  4820