json extract code example
Example 1: mariadb JSON_EXTRACT
+----+--------+-------+-------+---------------------------------+
| id | name | price | stock | attr |
+----+--------+-------+-------+---------------------------------+
| 2 | Shirt | 10.50 | 78 | {"size": 42, "colour": "white"} |
| 3 | Blouse | 17.00 | 15 | {"colour": "white"} |
+----+--------+-------+-------+---------------------------------+
SELECT name FROM clothes WHERE JSON_EXTRACT(attr, '$.size') = 42;
Example 2: json_extract in non native query
Query query = em.createQuery("select o from Product o FUNCTION('JSON_EXTRACT', o.des, '$.org') = :org");