最近发现mysql强大的功能,可以直接查询出整个json中具体某个值的数据:
json对应的字段内容是这样的:
msg_content对应的内容就是json字段:
{
"fileName":"测非编1.mp4",
"filePath":"/mnt/windows/folderscan/uploadAndTask/91/测非编1.mp4",
"taskName":"截取首帧失败",
"taskFailStage":"1"
}
原始数据是这样的:
SELECT
id,
msg_code AS msgCode,
read_flag AS readFlag,
msg_content ->> '$.mediaId' as mediaId,
msg_content ->> '$.fileName' as fileName,
msg_content ->> '$.taskName' as taskName,
msg_content ->> '$.filePath' as filePath
FROM
notice_msg
WHERE
receive_user_id = '79';
拆分开查询后的结果是这样:
当字段为json数组的时候:
[
{
"time": 1594034025178,
"stage"