Reputation: 569
So, the JSON structure looks like that:
{
"pixel.uuid": "1ca86b7d7505c48363b2a5d9dde0c7e4",
"innerWidth": "1440"
}
Question: How do I select "pixel.uuid"? I tried these combinations:
select json->"$.pixel.uuid" from TrackingData_experimental
select json->"$.pixel\.uuid" from TrackingData_experimental
select json->{"$.pixel.uuid"} from TrackingData_experimental
select JSON_EXTRACT(json, '$.pixel.uuid') from TrackingData_experimental
But with no luck. Thank you!
Upvotes: 1
Views: 651
Reputation: 562408
Delimit the key in double-quotes:
mysql> select json->'$."pixel.uuid"' from TrackingData_experimental;
+------------------------------------+
| json->'$."pixel.uuid"' |
+------------------------------------+
| "1ca86b7d7505c48363b2a5d9dde0c7e4" |
+------------------------------------+
If you want the value returned unquoted, do this:
mysql> select json->>'$."pixel.uuid"' from TrackingData_experimental;
+----------------------------------+
| json->>'$."pixel.uuid"' |
+----------------------------------+
| 1ca86b7d7505c48363b2a5d9dde0c7e4 |
+----------------------------------+
Upvotes: 1