In MySQL, you can use the JSON_OBJECT()
function to create a JSON object from a list of key/value pairs. You provide each key/value pair as two separate arguments. Each pair becomes a key/value pair in the resulting JSON object.
You must provide an even number of arguments (otherwise, you’d have an incomplete pair somewhere in your list of arguments).
The function also accepts an empty list (i.e. you provide no arguments). In this case, you’ll get an empty object.