JSON Functions
# StreamSQL JSON Functions
JSON functions are used for handling JSON data.
# TO_JSON - Convert to JSON Function
Syntax: to_json(value)
Description: Converts a value to a JSON string.
# FROM_JSON - Parse from JSON Function
Syntax: from_json(json_str)
Description: Parses a value from a JSON string.
# JSON_EXTRACT - JSON Extract Function
Syntax: json_extract(json_source, path)
Description: Extracts the value at the specified path from a JSON string, Map, or Array. Supports nested objects and array indexing.
Parameters:
json_source: Input data; can be a JSON string, Map, or Array objectpath: Extraction path; supports.for field access and[]for array index or Map key
Examples:
-- Extract basic field
json_extract('{"name": "Alice"}', 'name') -- returns "Alice"
json_extract('{"name": "Alice"}', '$.name') -- returns "Alice"
-- Extract nested field
json_extract('{"user": {"address": {"city": "New York"}}}', 'user.address.city') -- returns "New York"
json_extract('{"user": {"address": {"city": "New York"}}}', '$.user.address.city') -- returns "New York"
-- Extract array element
json_extract('[10, 20, 30]', '[1]') -- returns 20
json_extract('[10, 20, 30]', '$[1]') -- returns 20
-- Complex nested extraction
json_extract('{"users": [{"name": "Alice"}, {"name": "Bob"}]}', 'users[1].name') -- returns "Bob"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# JSON_VALID - JSON Validation Function
Syntax: json_valid(json_str)
Description: Validates whether a string is valid JSON.
# JSON_TYPE - JSON Type Function
Syntax: json_type(json_str)
Description: Returns the type of a JSON value.
# JSON_LENGTH - JSON Length Function
Syntax: json_length(json_str)
Description: Returns the length of a JSON array or object.
# 📚 Related Documentation
- DateTime Functions - Learn detailed usage of datetime functions
- Hash Functions - Learn detailed usage of hash functions
- SQL Reference - View complete SQL syntax reference
Edit this page on GitHub (opens new window)
Last Updated: 2026/01/19, 13:29:44