json_loads
Deserializes a JSON-formatted string into a native object (dictionary, list, string, number, etc.). This is useful when a field contains JSON data stored as a string that needs to be parsed for further processing.
Syntax
json_loads(s)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| s | string | Yes | A string containing valid JSON data. |
Returns
Type: any (dict, list, string, number, boolean, or null)
The native object represented by the JSON string.
Examples
Parse a JSON object string:
json_loads([config_json])
If config_json is '{"enabled": true, "timeout": 30}', the result is the dictionary {"enabled": true, "timeout": 30}.
Parse and then extract a value:
json_path("name", json_loads([user_json]))
If user_json is '{"name": "Alice", "role": "admin"}', the result is "Alice".
Parse a JSON array:
json_loads([tags_json])
If tags_json is '["network", "urgent", "vpn"]', the result is the list ["network", "urgent", "vpn"].
Notes
- The input must be a valid JSON string. If the string is malformed, the function raises a
JSONDecodeError. - This is the inverse of
json_dumps. - Commonly used in combination with
json_pathorjson_path_multito extract values from JSON strings stored in text fields.
Comments
0 comments
Please sign in to leave a comment.