- 
  Notifications
 
You must be signed in to change notification settings  - Fork 1.5k
 
JAVA-5736: Add bsonNamingStrategy option to support snake_case naming strategy #1589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @leesungbin 
Thank you for the PR! We really appreciate your contribution.
However, the current Regexp-based approach doesn’t fully account for all use cases. According to the Kotlin language specification, variable names can include Unicode characters, such as Cyrillic characters. For example, a variable name like имяПеременной would not be handled correctly.
Additionally, backtick names (e.g., `my Class`) won’t be transformed as expected.
A possible refactor could leverage the existing implementation of SnakeCase in kotlinx.serialization. You can refer to this implementation:
SnakeCase in kotlinx.serialization.
Also, please ensure the tests align with the transformation rules and acronyms defined in:
JsonNamingStrategy Transformation Rules.
Looking forward to your updates! Let me know if you need any clarification.
Hello @nhachicha, thanks for providing such detailed comments.
I have copied the convertCamelCase logic from the kotlinx.serialization library and used it to convert camelCase to snake_case.
Additionally, I introduced an error condition for scenarios where decoding snake_case to camelCase is ambiguous (for instance, my_http_auth could be interpreted as myHttpAuth or myHTTPAuth).
Please give it a look. Thanks!
Thanks for iterating on this @leesungbin can you please rebase against JAVA-5736 branch?
cf8cfed to
 ee1e3e2  
 Compare
 
 Sure, I've rebased on to JAVA-5736.
Uh oh!
There was an error while loading. Please reload this page.
Ticket
JAVA-5736
Description
This PR adds bsonNamingStrategy property to BsonConfiguration to support snake_case naming strategy.
Testing
ran ./gradlew check