MariaDB JSON_COMPACT() Explained

In MariaDB, JSON_COMPACT() is a built-in function that removes all unnecessary spaces from a JSON document, so that it’s as short and compact as possible, and returns the result.

This can be handy for when you need to store JSON data in a database column, and you don’t want the JSON documents to use up any more space than is necessary.

For the opposite effect (i.e. to prettify a JSON document by adding indents and spreading it over multiple lines), use the JSON_DETAILED() function.

Continue reading

MariaDB JSON_ARRAYAGG() Explained

In MariaDB, JSON_ARRAYAGG() is a built-in function that returns a JSON array containing an element for each value in a given set of JSON or SQL values.

The function acts on a column or an expression that evaluates to a single value. It enables you to aggregate a result set as a single JSON array. Each row of the result set ends up as a single element in the array.

Continue reading

How to Reference JSON Keys that Contain Special Characters when using OPENJSON, JSON_QUERY, and JSON_VALUE (SQL Server)

If you’re using a T-SQL function such as OPENJSON(), JSON_QUERY(), or JSON_VALUE(), you might be wary of any non-alphanumeric characters that might be in the JSON document that you’re working with. Especially if those special characters are in the key names, and you need to reference those key names.

Continue reading