I need help on how to parse JSON data in MySQL.
I can parse a column named config containing data such as:
{\"encounterId\":\"f45bf821-98e1-4496-82ef
Here's a solution in MySQL 5.7 syntax:
select be.config->'$.encounterId' AS eid
, be.config->'$.providerId' AS gender
, be.config->'$.patientId' AS pid
, be.config->'$.formId' AS formid
from bencounter be \G
Output:
*************************** 1. row ***************************
eid: "f45bf821-98e1-4496-82ef-047971e168cb"
gender: "38001853-d2e1-4361-9fff-cfca1aedf406"
pid: "f4d04edb-652f-427c-ac25-6fecbda2a0aa"
formid: "ETAT"
Remember that field keys in JSON are case-sensitive. For example, 'formId'
is not the same as 'formid'
.