Home > Net >  extract nested json value with mysql
extract nested json value with mysql

Time:08-24

customfields
'{"6": {"name": "Confirmed?", "type": "Checkbox", "value": "true"}, "7": {"name": "Estimated/Actual Ship date", "type": "Date", "value": "2022-08-08 00:00:00"}'

I'd like to extract true from id 6. I've tried select json_extract(customFields, '$.6.value')

CodePudding user response:

You need to quote 6 since it's not a valid identifier.

select json_extract(customfields, '$."6".value') from mytable;

This is in the documentation:

A period followed by a key name names the member in an object with the given key. The key name must be specified within double quotation marks if the name without quotes is not legal within path expressions (for example, if it contains a space).

  • Related