-
Notifications
You must be signed in to change notification settings - Fork 624
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
add functions for creating JsonPrimitives from unsigned numbers #2160
add functions for creating JsonPrimitives from unsigned numbers #2160
Conversation
@@ -121,4 +121,54 @@ class JsonPrimitiveSerializerTest : JsonTestBase() { | |||
assertEquals(string, jvmExpectedString) | |||
} | |||
} | |||
|
|||
@Test |
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.
Please also add serialization tests, like JsonUnquotedLiteralTest
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.
I've added parametrizedTest {}
, like in JsonUnquotedLiteralTest
* The value will be encoded as a JSON number. | ||
*/ | ||
@ExperimentalSerializationApi | ||
public fun JsonPrimitive(value: UByte): JsonPrimitive = JsonPrimitive(value.toULong()) |
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.
The other functions use nullable parameters. I think for unsigned types we should do the same.
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.
I believe we shouldn't, and nullability for other functions is rather a mistake.
It will cause unnecessary boxing, while bringing no benefit whatsoever: for nullable types, Nothing?
overload will be chosen
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.
I tried adding nullability, but I ran into issues: #2130 (comment)
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.
@qwwdfsad, shouldn't we leave an explanatory comment so that in the future there will be no questions why a different approach is used?
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.
Would be nice to have
8188f0c
to
e668b06
Compare
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 for the contribution!
fix #2130
Adds
JsonPrimitive()
overloads for constructingJsonPrimitive
from unsigned numbers