Dec 17

JSON Array Single MySQL Insert and Update

This is another quick one. I wanted to insert a JSON array into MySQL with a single insert and, on duplicate key update. This is how you get it done:

Say you have a JSON array like this:

[{"num":"222","desc":"seconds","freq":11,"type":"hour","active":false},{"num":"1234","desc":"forths","freq":22,"type":"day","active":false},{"num":"3333","desc":"thirds","freq":33,"type":"week","active":true}]

Continue reading