JSON_PARSE
Description
The JSON_PARSE
function is used to parse a JSON-formatted string into a JSON type. The parsed JSON type will automatically remove extra spaces when output, and the order of fields is not guaranteed to be exactly the same as the original JSON string. PARSE_JSON
is an alias for the JSON_PARSE
function, and both have the same functionality.
Syntax
Parameters
str
: The JSON format string that needs to be parsed.
Return Result
- Returns the parsed JSON type.
Usage Example
Example 1: Parse a simple JSON string
Example 2: Parsing Nested JSON Strings
Example 3: Parsing a JSON string containing an array
Example 4: Parsing a JSON string containing numbers and boolean values
Notes
- Ensure that the input string is in a valid JSON format, otherwise it may cause parsing failure.
- When handling complex JSON strings, pay attention to the indentation and use of quotes to ensure correct parsing.
- Since JSON types automatically remove extra spaces when outputting, the order of fields in the output may differ from the original input.