-
Notifications
You must be signed in to change notification settings - Fork 623
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
HOCON: parse strings into integers and booleans if possible #1795
HOCON: parse strings into integers and booleans if possible #1795
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.
Thank you for the PR, great work! I don't have objections to it except a few comments
formats/hocon/src/test/kotlin/kotlinx/serialization/hocon/HoconValuesTest.kt
Outdated
Show resolved
Hide resolved
@sandwwraith Thank you for the review. I think I addressed your concerns. |
fun `deserialize map with integers`() { | ||
val configString = """m = { 2: 1, 4: 3 }""" | ||
val obj = deserializeConfig(configString, WithMap.serializer()) | ||
with(obj) { |
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.
Pls remove with
also here
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.
done
fun `deserialize map with integers as strings`() { | ||
val configString = """m = { "2": "1", "4":"3" }""" | ||
val obj = deserializeConfig(configString, WithMap.serializer()) | ||
with(obj) { |
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.
and here
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.
👍 sorry for not having checked this thoroughly before.
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.
Thanks again!
HOCON suggest that parsers should apply certain automatic conversions, especially when reading integers/numbers or booleans from strings (1).
This is an attempt to resolve the most pressing issues that would resolve #1439 .
This PR changes parsing so that it now relies on the parsing capabilities for the
Config
class, and not on the obtainedConfigValues
.This PR does not claim to cover all automatic conversions mentioned in 1, but is focused on parsing numbers and booleans from strings only.