Home > Blockchain >  Access JSON column
Access JSON column

Time:05-12

How can I access values in the status and date columns stored as JSON? Please, have a look at an example row below.

{"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03-30"}}

CodePudding user response:

Demo:

set @j = '{"1":{"status":true,"date":"2022-03-30"},"3":{"status":true,"date":"2022-03-30"}}';

select json_extract(@j, '$."1".status') as status;
 -------- 
| status |
 -------- 
| true   |
 -------- 

In this case, it may be unexpected that you need to put double-quotes around "1" to use it in a JSON path.

  • Related