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.