By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
SET @data = '{
"Vocab": {
"username":"132423424",
"Mother": {
"code":"1",
"progress":"1",
"nextdate":"22-10-2020",
"lastcheck":"22-10-2020"
},
"Father": {
"code":"2",
"progress":"2",
"nextdate":"22-10-2020",
"lastcheck":"22-10-2020"
}
}
}';
SET @data2 = '{ "code": "3", "progress":"1", "nextdate":"22-12-2020", "lastcheck":"22-12-2020" }'
SELECT JSON_PRETTY(
REPLACE(
REPLACE(
REPLACE(
JSON_INSERT(@data, '$.Vocab.Brother', (@data2))
,'\\"','"')
,'"{','{')
,'}"','}') ) AS 'New JSON';
New JSON |
---|
{ "Vocab": { "Father": { "code": "2", "nextdate": "22-10-2020", "progress": "2", "lastcheck": "22-10-2020" }, "Mother": { "code": "1", "nextdate": "22-10-2020", "progress": "1", "lastcheck": "22-10-2020" }, "Brother": { "code": "3", "nextdate": "22-12-2020", "progress": "1", "lastcheck": "22-12-2020" }, "username": "132423424" } } |