Skip to content
Advertisement

MySQL 5.7 equivalent to PHP’s json_decode()?

I’m converting some php scripts into mysql stored procedures and have come across the usage of php’s json_decode() on a result set’s data. It occurs on a field which is stored as a mediumtext,utf8,utf8_unicode_ci

How can I perform the ‘json_decode()’ process using pure MySQL?

Sample data from the field:

{“93489”:{“X1”:{“net”:164,”vat”:33.6},”X2″:{“net”:0,”vat”:0}}}

Advertisement

Answer

You can use JSON_EXTRACT function:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement