iam using mysql 5.7.17 (latest version)
this is my table samp1
mysql> select *from samp1;
+-----+----------------------------------------------------------------+
| id | jdoc |
+-----+----------------------------------------------------------------+
| 101 | {"k1": 12, "k2": 34} |
| 111 | {"k1": 12, "k2": 34, "k3": {"L1": "value1", "L2": "value2"}} |
| 112 | {"k1": 12, "k2": 34, "k3": {"L1": "value1", "L2": "value2"}} |
| 125 | {"7": "123", "8": 10, "9": "hey", "10": ["dar", "sne", "swo"]} |
+-----+----------------------------------------------------------------+
when i use below query it's executing properly
select id,jdoc -> "$.k3" as f from samp1 ;
but when i use this query with single number key. it throwing error,why?
select id,jdoc -> "$.7" as f from samp1 ;
ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 3.
Mysql 5.7 ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 3 - Stack Overflow Mysql 5.7 ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 3 Bookmark this question. Show activity on this post. but when i use this query with single number key. it throwing error,why?
Mysql 5.7 ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 3 Bookmark this question. Show activity on this post. but when i use this query with single number key. it throwing error,why? select id,jdoc -> "$.7" as f from samp1 ; ERROR 3143 (42000): Invalid JSON path expression.
Description: The path argument is a recurring theme in many of the JSON functions. Yet there seems to be no single piece of documentation that clearly describes the syntax of JSON paths in MySQL.
The error is around character position 2 in '$.["bla\'. Suggested fix:Please support square brace property access operator in path argument to JSON functions. [1 Nov 2015 11:34] MySQL Verification Team
This should work:
select id,jdoc -> '$."7"' as f from samp1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With