[MDEV-12982] JSON_EXTRACT returns data for invalid JSON Created: 2017-06-02  Updated: 2017-09-12  Resolved: 2017-09-12

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2.5
Fix Version/s: 10.2.9

Type: Bug Priority: Critical
Reporter: Anders Karlsson Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux CentOS 6.4



 Description   

The function JSON_EXTRACT will return data and will not raise an error, even if the provided JSON is invalid JSON. It will not check the whole thing, so if the JSON up to the point of the provided JSON path is correct, that will be returned, even if the rest of the JSON data is invalid. For example

MariaDB [(none)]> select JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo');
+------------------------------------------------------------+
| JSON_EXTRACT('{"foo": "bar" foobar foo invalid ', '$.foo') |
+------------------------------------------------------------+
| "bar"                                                      |
+------------------------------------------------------------+
1 row in set (0.00 sec)


Generated at Thu Feb 08 08:02:00 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.