Home  >  Article  >  Database  >  Get the value corresponding to KEY from the string of a serialized array.

Get the value corresponding to KEY from the string of a serialized array.

大家讲道理
大家讲道理Original
2016-11-12 09:32:241270browse

delimiter $$
 
create function get_from_serialized_json 
( in_string varchar(255), 
  in_key varchar(255) )
  returns varchar(255)
BEGIN
return trim( '"' from
   substring_index(
    substring_index(
        substring(trim("}" FROM in_string ), locate(concat("\"",in_key,"\""), in_string  )+1 
    ) , ";",2 
   ), ":",-1 )) ;
END$$

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn