+--------------------------------------------------------------+ mysql> SELECT JSON_VALUE(’{"item": "shoes", "price": "49.95"}’, ’$.price’ -> RETURNING DECIMAL(4,2)) AS price; +-------+ | price | +-------+ | 49.95 | +-------+ 

The statement SELECT JSON_VALUE( json_doc , path  RETURNING type )  is equivalent to the following statement: 

SELECT CAST( JSON_UNQUOTE( JSON_EXTRACT( json_doc , path ) ) AS type ); 

JSON_VALUE()  simplifies creating indexes on JSON columns by making it unnecessary in many cases to create a generated column and then an index on the generated column. You can do this when creating a table t1  that has a JSON  column by creating an index on an expression that uses JSON_VALUE()  operating on that column (with a path that matches a value in that column), as shown here: 

CREATE TABLE t1( j JSON, INDEX i1 ( (JSON_VALUE(j, ’$.id’ RETURNING UNSIGNED)) ) ); 

The following EXPLAIN  output shows that a query against t1  employing the index expression in the WHERE  clause uses the index thus created: 

mysql> EXPLAIN SELECT * FROM t1 -> WHERE JSON_VALUE(j, ’$.id’ RETURNING UNSIGNED) = 123\G *************************** 1. row *************************** id: 1 select_type: SIMPLE table: t1 partitions: NULL type: ref possible_keys: i1 key: i1 key_len: 9 ref: const rows: 1 filtered: 100.00 Extra: NULL 

This achieves much the same effect as creating a table t2  with an index on a generated column (see Indexing a Generated Column to Provide a JSON Column Index), like this one: 

CREATE TABLE t2 ( j JSON, g INT GENERATED ALWAYS AS (j->"$.id"), INDEX i1 (j) ); 

The EXPLAIN  output for a query against this table, referencing the generated column, shows that the index is used in the same way as for the previous query against table t1 : 

mysql> EXPLAIN SELECT * FROM t2 WHERE g = 123\G *************************** 1. row *************************** id: 1 

