JSON Column Type
MySQL 5.7+ supports a native JSON column type that validates and stores JSON efficiently. Unlike TEXT, JSON columns are indexed and queryable.
MySQL 5.7+ supports a native JSON column type that validates and stores JSON efficiently. Unlike TEXT, JSON columns are indexed and queryable.
CREATE TABLE products (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
attributes JSON
);
INSERT INTO products (name, attributes)
VALUES ('Laptop', '{"color": "black", "ram": 16, "ssd": true}');
JSON columns reject invalid JSON at insert time — no need for application-level validation.