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

[Help] How to deserialize/parse lists after 1.0? #1224

Closed
hykilpikonna opened this issue Nov 30, 2020 · 2 comments
Closed

[Help] How to deserialize/parse lists after 1.0? #1224

hykilpikonna opened this issue Nov 30, 2020 · 2 comments
Labels

Comments

@hykilpikonna
Copy link

hykilpikonna commented Nov 30, 2020

I used to use A.serializer().list to get a list serializer, but this extension is removed after 1.0. And ArrayListSerializer is removed too. Is there a replacement?

Answers in this issue are deprecated: #179

Code:

@Serializable
data class W(val w: String)

val jsonString = """[{"w": "1"}, {"w": "2"}]"""

// Old method:
val obj = json.parse(W.serializer().list, jsonString)
@ahimberg
Copy link

ahimberg commented Dec 1, 2020

Have you tried this:
val obj = json.decodeFromString(ListSerializer(W.serializer()), jsonString)

@sandwwraith
Copy link
Member

Yes, ListSerializer() is a correct replacement for list extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants