Skip to main content

Module case

Module case 

Source
Expand description

Case conversion for API: request keys camelCase -> snake_case (for DB), response keys snake_case -> camelCase (for client).

Functions§

hashmap_keys_to_snake_case
Convert a HashMap’s keys from camelCase to snake_case. Returns a new map.
object_keys_to_camel_case
Convert all keys of a JSON object from snake_case to camelCase (in place). Used for API responses so the client receives camelCase keys.
object_keys_to_snake_case
Convert all keys of a JSON object from camelCase to snake_case (in place). Used for request bodies and query params so we use snake_case for DB column names.
to_camel_case
Convert a single identifier from snake_case to camelCase. e.g. “user_id” -> “userId”, “created_at” -> “createdAt”
to_snake_case
Convert a single identifier from camelCase to snake_case. e.g. “userId” -> “user_id”, “createdAt” -> “created_at”
value_keys_to_camel_case
Apply camelCase conversion to a Value. If it’s an object, converts its keys; otherwise no-op.
value_keys_to_camel_case_recursive
Recursively apply camelCase to all object keys in a Value (objects and arrays of objects).
value_keys_to_snake_case
Apply snake_case conversion to a Value. If it’s an object, converts its keys; otherwise no-op.