SELECT
      JSON_ARRAYAGG(
        JSON_OBJECT(TABLESPACE_NAME VALUE 
          JSON_OBJECT(
            'contents'   VALUE CONTENTS, 
            'used_bytes' VALUE USED_BYTES, 
            'max_bytes'  VALUE MAX_BYTES, 
            'free_bytes' VALUE FREE_BYTES, 
            'used_pct'   VALUE USED_PCT,
            'status'     VALUE STATUS 
          ) 
        ) RETURNING CLOB 
      )
    FROM(
    SELECT  a.tablespace_name,
    a.CONTENTS contents,
    ROUND (((c.BYTES - NVL (b.BYTES, 0)) / c.BYTES) * 100,2) used_pct,
    c.BYTES max_bytes,
    ROUND (c.BYTES - NVL (b.BYTES, 0)) used_bytes,
    ROUND (NVL (b.BYTES, 0), 2) free_bytes,
    DECODE(a.STATUS, 'ONLINE', 1, 'OFFLINE', 2, 'READ ONLY', 3, 0) AS STATUS
  FROM dba_tablespaces a,
       (    SELECT   tablespace_name, 
                  SUM (BYTES) BYTES
           FROM   dba_free_space
       GROUP BY   tablespace_name
       ) b,
      (    SELECT   COUNT (1) DATAFILES, 
                  SUM (BYTES) BYTES, 
                  tablespace_name
           FROM   dba_data_files
       GROUP BY   tablespace_name
    ) c
  WHERE b.tablespace_name(+) = a.tablespace_name 
    AND c.tablespace_name(+) = a.tablespace_name)