-
Notifications
You must be signed in to change notification settings - Fork 619
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
Stringify writes null values incorrectly #289
Labels
Comments
Will print |
Ah must be my current version. I'll look into this and see if I can resolve it by updating. Thanks for looking into this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I mentioned this in issue #58 But I think it is it's own issue altogether after doing some digging.
Here's an example of a data class that I serialize which has an optional serializable parameter:
Currently with how the Kotlinx serialization library is written we write to our JSON map the value of
null
as a Kotlin String"null"
.So for the example above the resulting JSON.stringify() return value would look as follows:
Cool so this will mean I'm not going to change this value when I POST this payload right? NOPE
"null"
is not a valid JSON null value for the API I'm sending POST requests to. Now I'll admit I don't have much experience with API's (I'm learning 🤓). But for my use case in particular this a huge issue. Now for what I think could be the solution.In the following file:
https://github.com/Kotlin/kotlinx.serialization/blob/master/runtime/common/src/main/kotlin/kotlinx/serialization/json/JsonParser.kt#L23
Change this line:
internal const val NULL = "null"
to
internal const val NULL = null
The text was updated successfully, but these errors were encountered: