SQLite JSON()

In SQLite, the json() function converts raw text that looks like JSON into actual JSON.

We pass a JSON string as an argument when we call the function. The json() function then checks that the argument is a valid JSON string and returns a minified version of that JSON string. If the argument is not a well-formed JSON string, then an error is thrown.

However, the json() function was not designed to test whether or not a value is valid JSON. To do that, use the json_valid() function instead.

Continue reading

SQLite SUBSTRING() Explained

In SQLite, substring() is an alias for substr().

It returns a substring from a string, based on a given starting location within the string. Two arguments are required, and a third optional argument is accepted.

The substring() naming was introduced in SQLite 3.34.0, which was released on 1st December 2020. The reason that the substring() syntax was introduced was for compatibility with SQL Server.

Continue reading