Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql 5.7 ERROR 3143 (42000): Invalid JSON path expression. The error is around character position 3

Tags:

json

mysql

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.
like image 794
sai Avatar asked Jan 31 '17 12:01

sai


People also ask

What is error 3143 in MySQL?

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?

What is error 3143 (42000)?

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.

What is the syntax of JSON path argument in MySQL?

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.

How to fix JSON error $[BLA\]?

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


1 Answers

This should work:

select id,jdoc -> '$."7"' as f from samp1
like image 142
Ike Walker Avatar answered Oct 19 '22 03:10

Ike Walker