CREATE OR REPLACE FUNCTION fix_pctile(p_txt IN CLOB)
  RETURN CLOB DETERMINISTIC
IS
  -- key must be a number
  c_num CONSTANT VARCHAR2(200) := '([+-]?\d+(\.\d+)?([eE][+-]?\d+)?)';

  -- value can be a number OR the literal null
  -- capture group 4 will hold either the number OR 'null'
  c_val CONSTANT VARCHAR2(200) := '(' || c_num || '|null)';
BEGIN
  IF p_txt IS NULL THEN
    RETURN NULL;
  END IF;

  RETURN REGEXP_REPLACE(
           REGEXP_REPLACE(
             p_txt,
             '\{key\s*=' || c_num || '\s*,\s*value\s*=' || c_val || '\s*\}',
             '{"key":\1,"value":\4}'
           ),
           '''',
           '"'
         );
END;
/