Stringcase module
The stringcase module provides utilities for converting string formats between camelCase and snake_case, particularly for handling JSON-like data structures. These tools are essential for developers working in environments where consistent naming conventions are required, such as in API development or data transformation tasks. This module includes functions for converting individual strings from camelCase to snake_case and vice versa, as well as tools for transforming the keys of JSON-like dictionaries. Additionally, a decorator is provided to automatically convert the keys of dictionary arguments passed to a function.
- jsify.stringcase.json_camel_to_snake(json, replace=None)[source]
Converts the keys of a JSON-like dictionary from camelCase to snake_case.
- Parameters:
json (dict) – The JSON-like dictionary with camelCase keys to be converted.
replace (dict, optional) – A dictionary to specify replacements for certain keys after conversion to snake_case.
- Returns:
The JSON-like dictionary with keys converted to snake_case.
- Return type:
dict
- jsify.stringcase.text_camel_to_snake(text, replace=None)[source]
Converts a camelCase string to snake_case.
- Parameters:
text (str) – The camelCase string to be converted.
replace (dict, optional) – A dictionary to specify replacements for certain keys after conversion to snake_case.
- Returns:
The converted snake_case string.
- Return type:
str
- jsify.stringcase.text_snake_to_lower_camel(text, replace=None)[source]
Converts a snake_case string to lowerCamelCase.
- Parameters:
text (str) – The snake_case string to be converted.
replace (dict, optional) – A dictionary to specify replacements for certain keys after conversion to lowerCamelCase.
- Returns:
The converted lowerCamelCase string.
- Return type:
str