Skip to main content

Change Column Case

It lets the user change the case of the column names.

This transformation expects user to provide below inputs:

Input ArgumentsMandatoryDefault ValueDescription
target-case-typeYes-Supported case types (lower,upper,snake,kebab,camel,pascal)
source-case-typeNolowerSupported case types (snake,kebab,camel,pascal)

Below is a quick helper chart to understand commonly used case types and their general usage

Input ArgumentsExampleUsage
CamelmyVariableNameUsed for variables, methods, and parameter names
PascalMyClassNameUsed for class names and type names
Snakemy_variable_nameUsed for variable names in some scripting languages
Kebabmy-variable-nameUsed for configurations, file names, URLs, and command-line arguments

For example, consider we have below restonomer response in json:

{
"col_a": "1",
"COL_B": "2"
}

Now, as we know all these columns are in snake-case, suppose the requirement is to transform case of all columns to camel case.

Then, user can configure the ChangeColumnCase transformation in the below manner:

{
type = "ChangeColumnCase"
target-case-type = "camel"
source-case-type = "snake"
}

The transformed response will now have the columns with the desired case type:

{
"colA": "1",
"colB": "2"
}

Remember that, for converting the case to "lower" or "upper" user need not give source-case-type as it will not matter for the conversion. However, for any other target case type user needs to provide an appropriate source-case-type. Otherwise, Restonomer will error out.