1

I have a JSON typed column and I try to use the native JSON functions that MySQL allow me to use: https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html

I am especially looking for a way to update the JSON. Adding several values in the same JSON Array. The documentation is a bit rough on this point.

I know that it's not recommended to store JSON in a DB but I don't have the choice.

1 Answer 1

8

After a few minutes I managed to create my query:

UPDATE table 
SET field=JSON_ARRAY_INSERT(field, "$[0]", JSON_OBJECT('c', 0.5, 'd', 0.9)) 
WHERE id=12;

I'm sure I will forget this, so I created this page for my future self.

Good luck and Have fun!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.