How to parse a JSON string into an object and serialize (stringify) an object back to JSON in SQL. PostgreSQL has native json/jsonb types; MySQL uses JSON_EXTRACT and JSON_OBJECT. Need to clean up the JSON first? Use the formatter & validator.
-- PostgreSQL: cast text to jsonb
SELECT '{"id":1}'::jsonb AS obj;
SELECT obj->>'id' AS id FROM t;
-- Build JSON from columns
SELECT jsonb_pretty(
jsonb_build_object('id', id, 'name', name)
) FROM t;
PostgreSQL has native json/jsonb types; MySQL uses JSON_EXTRACT and JSON_OBJECT. Parse with the snippet above; the result is a native object/map you can read.
Use the stringify snippet above with indentation, or paste your JSON into the formatter on this page.