In MySQL, the JSON_LENGTH()
function returns the length of a JSON document.
When you call this function, you provide the JSON document as an argument. You can also provide a path argument to return the length of a value within the document.
In MySQL, the JSON_LENGTH()
function returns the length of a JSON document.
When you call this function, you provide the JSON document as an argument. You can also provide a path argument to return the length of a value within the document.
In MySQL, the JSON_DEPTH()
function returns the maximum depth of a JSON document.
When you call this function, you provide the JSON document as an argument.
In MySQL, the JSON_TYPE()
function returns the type of a JSON value. More specifically, it returns a utf8mb4
string indicating the value’s type.
You provide the JSON value as an argument.
In MySQL, the JSON_STORAGE_FREE()
function shows how much storage space was freed up after a JSON Document was updated.
For a JSON column value, it shows how much storage space was freed in its binary representation after it was updated in place using JSON_SET()
, JSON_REPLACE()
, or JSON_REMOVE()
.
For a JSON document (or a string which can be parsed as one), this function returns 0
.
In MySQL, the JSON_STORAGE_SIZE()
function returns the number of bytes used to store the binary representation of a JSON document.
You provide the JSON document as an argument.
When the argument is a JSON
column, this function returns the space used to store the JSON document as it was inserted into the column, prior to any partial updates that may have been performed on it afterwards.
When the argument is a string, the function returns the amount of storage space in the JSON binary representation that is created by parsing the string as JSON and converting it to binary.
In MySQL, the JSON_PRETTY()
function provides pretty-printing of JSON values. It returns the JSON values in a nicely formatted way, which makes it easier for us humans to read.
You provide the JSON values as an argument to the function. The function then returns those values formatted according to its formatting rules.
In MySQL, the JSON_SEARCH()
function returns the path to a given string in a JSON document.
You provide the JSON document as an argument to the function. You also provide the argument that determines the actual string to search (including any escape characters), as well as a keyword to indicate whether to return the path of all instances or just one.
In MySQL, the JSON_KEYS()
function returns keys from the top level value of a JSON object. The keys are returned as a JSON array, or, if a path
argument is given, the top-level keys from the selected path.
You provide the JSON document as an argument to the function.
You can also (optionally) provide a second argument to specify where the “top-level” path starts from within the JSON document.
In MySQL, the JSON_EXTRACT()
function returns data from a JSON document. The actual data returned is determined by the path you provide as an argument.
You provide the JSON document as the first argument, followed by the path of the data to return. You can also provide multiple paths to return data from multiple places in the document.
In MySQL, the JSON_CONTAINS_PATH()
function tests whether or not a specified path is found in the given JSON document.
If the path is found, JSON_CONTAINS_PATH()
returns 1
, otherwise it returns 0
.