SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
WITH t AS ( SELECT ' [ {"id": "123", "code": "abc"}, {"ID": "456", "CODE": "def"}, {"iD": "789", "cOdE": "xYz"} ] '::JSON obj ), p AS ( SELECT JSON_AGG ( JSON_OBJECT ( ARRAY(SELECT LOWER(key) FROM JSON_EACH_TEXT(e)), ARRAY(SELECT value FROM JSON_EACH_TEXT(e)) ) ) obj FROM t CROSS JOIN JSON_ARRAY_ELEMENTS(t.obj) e ) SELECT j.* FROM p CROSS JOIN JSON_TO_RECORDSET(p.obj) j ( id BIGINT, code TEXT );

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear