8000 Support new configuration that handles digit as a delimiter when converting to snake_case · Issue #2137 · circe/circe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Support new configuration that handles digit as a delimiter when converting to snake_case #2137
Open
@LimJiGyu

Description

@LimJiGyu

There is a need for a new configuration logic that can handle a digit as a delimiter, including capital letters.

For Instance when converting PascalCase to snake_case, we should transform it as follows.
AddressLine1 -> address_line1 (incorrect)
AddressLine1 -> address_line_1 (correct)
(I think this online converting tool is using the logic above. Try some cases in this site Text to Snake Case Online Conterter)

However, the existing configuration in renaming object (modules/core/shared/src/main/scala-3/io/circe/derivation/renaming.scala) does not support this particular case.

Therefore, I would like to suggest the addition of an option to utilize this new configuration, allowing for a different swap pattern like the one described above.
existing:
private val basePattern: Pattern = Pattern.compile("([A-Z]+)([A-Z][a-z])") private val swapPattern: Pattern = Pattern.compile("([a-z\\d])([A-Z])")

new option:
private val basePattern: Pattern = Pattern.compile("([A-Z]+)([A-Z][a-z])") private val swapPattern: Pattern = Pattern.compile("([a-z\\d])([\\dA-Z])")

Furthermore, even if such selectable options are provided, I believe it would be ideal to offer them in an extended form that does not affect the existing Configuration we currently use.

If you have any recommendations or suggestions, I would greatly appreciate your input. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0