Bug #76598 MySQL JSON UDFs: json_extract does not appear to unescape quotes within JSON

Submitted: 6 Apr 2015 4:00 Modified: 6 Apr 2015 7:45
Reporter: Jason Baumgartner Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: JSON User-defined function ( UDF ) Severity:S3 (Non-critical)
Version:0.4.0 OS:Linux (Ubuntu 14.04)
Assigned to: CPU Architecture:Any
Tags: mysql-json-udfs-0.4.0

[6 Apr 2015 4:00] Jason Baumgartner
Description:
Valid JSON requires escaping quotes within key values.  Example:

{"string":"This is \"some quoted\" text."}

When decoded, the "string" key should be:  This is "some quoted" text.

However, the json_extract does not appear to unescape the JSON escaped quotes.

How to repeat:
SELECT json_extract('{"string":"\\\"quoted text\\\""}','string');

+-----------------------------------------------------------+
| json_extract('{"string":"\\\"quoted text\\\""}','string') |
+-----------------------------------------------------------+
| \"quoted text\"                                           |
+-----------------------------------------------------------+

Suggested fix:
This should return "quoted text" (with the double quotes) and unescape the JSON escaped double quotes by removing the slashes.
[6 Apr 2015 7:45] MySQL Verification Team
Hello Jason Baumgartner,

Thank you for the report.
Observed this with 0.4.0 and MySQL 5.6.25.

Thanks,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.