I am not able to extract quoted strings using JSON_EXTRACT function in MySQL 5.7.
Sample input:
{
"email": "d'[email protected]",
"body": "I may have "random quotes '(single)/(double)" " in my source data"
}
Tried using,
SELECT
@valid_source := JSON_VALID(jsonString), NULL
IF(@valid_source, JSON_UNQUOTE(JSON_EXTRACT(jsonString, "$.email")), NULL)
I get an error stating: Invalid JSON text in argument 1 to function json_extract: "Missing a closing quotation mark in string." at position xxx
Any help will be appreciated, thanks!
JSON_VALIDfunctionNULLin your query, but that should give another error. Sure you posted the right query? Because other than that, it works for me: rextester.com/DVZ80948JSON_VALID()is really returning true, that's a bug in mysql, but using user-defined varibles for assignment inSELECTis not at deterministic, so your query as written does not actually prove that @valid_source is being set to true before theIF()is evaluated, if at all.