user image

Published in : 2022-03-31

How to read JSON key value from JSON object from Database (In Mysql or Sqlite database)?

PHP & Mysql

//My code snippetSELECT JSON_EXTRACT('{"id":"A0001","name":"shilpa"}', '$.name');

I want to extract key-value from Json stored in my database table. 

But above statement should return shilpa, In my case it is returning as “shilpa” (Returning value with double quotes)


On the UI side, I am using angular and I have to remove/replace double quotes with empty strings all the time! I am using Mysql 8.0 and SQLite DB v3.0

Is there a way to ignore double quotes which are appending in JSON_EXTRACT? 


Mohamed Atef Date : 2022-03-31

Best answers


Best answers


I believe you can remove the qoutes in this way

<?php$s = '"hello"';$final = str_replace('"', '', $s);echo $final;?>

and you can use foreach to extract the object and rebuild it 


you can use foreach only to get the key of the array like

foreach($arr as $key => $var){ echo $key . " " . $var;} 

Good luck

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

change user root privelige and password
Publish date: 2022-02-23 | Comments: 1

Tag: PHP & Mysql

How the image file have .php extension?
Publish date: 2022-03-01 | Comments: 2

Tag: PHP & Mysql

mysql service start not exist
Publish date: 2022-02-23 | Comments: 4

Tag: PHP & Mysql

ERROR 1410 (42000): You are not allowed to create a user with GRANT
Publish date: 2022-04-01 | Comments: 2

Tag: PHP & Mysql

php difference between two times in hours
Publish date: 2022-02-25 | Comments: 2

Tag: PHP & Mysql

phpmyadmin manual installation gives following error
Publish date: 2022-07-11 | Comments: 6

Tag: PHP & Mysql

PHP mail function goes to spam not inbox
Publish date: 2022-02-28 | Comments: 2

Tag: PHP & Mysql

MySQL - Lost connection to MySQL server during query - Required a solution.
Publish date: 2022-03-03 | Comments: 1

Tag: PHP & Mysql