Skip to content
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

Fix dynamic serialization for nullable values #1199

Conversation

ankushg
Copy link
Contributor

@ankushg ankushg commented Nov 12, 2020

Fixes #1198

Also adds tests to verify that other potential edge cases work as intended (empty lists, default parameters)

Updates kdoc comments to remove outdated disclaimer that polymorphism is not supported.

Comment on lines +143 to +148
encodeAndDecode(Sealed.serializer(), nullChild, objectJson) {
assertEquals("nullable_child", this.type)
assertEquals(nullChild.nullable, this.nullable)
assertEquals(nullChild.intField, this.intField)
assertEquals(3, fieldsCount(this))
}
Copy link
Contributor Author

@ankushg ankushg Nov 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific test is what was failing before.

It works fine for non-null values and/or array-based serialization, but was throwing a TypeError: Cannot convert undefined or null to object when it tried js("Object").keys(null) with object-based serialization

@ankushg
Copy link
Contributor Author

ankushg commented Nov 16, 2020

@shanshin This is my first contribution into kotlinx.serialization -- please let me know if there's anything I've overlooked!

Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants