create table item (
  id bigint primary key,
  caracteristiques jsonb
);

DO $$
DECLARE
    f TEXT;
BEGIN
    FOR f IN SELECT pg_catalog.pg_ls_dir('/tmp/json')
    LOOP
        IF right(f, 5) = '.json' THEN
            INSERT INTO item (id, caracteristiques)
            VALUES (
                replace(f, '.json','')::bigint,
                pg_read_file('/tmp/json/' || f)::jsonb
            )
            ON CONFLICT (id) DO UPDATE SET caracteristiques = EXCLUDED.caracteristiques;
        END IF;
    END LOOP;
END;
$$ LANGUAGE plpgsql;
