fuel icon indicating copy to clipboard operation
fuel copied to clipboard

How to Deserialize Lists with kotlinx-serialization

Open geofferyj opened this issue 3 years ago • 1 comments

The tilte refers; I've tried the method suggested in the Fuel documentation but it is no longer supported

how would one go about serializing and deserialising a list of objects.

geofferyj avatar Oct 05 '21 03:10 geofferyj

Given:

@Serializable 
data class MyClass(
  val x : Int
)

You can do

val (_, _, result) = "http://localhost:1080".httpGet()
         .responseObject(
            loader = ListSerializer(MyClass.serializer()),
            json = Json.Default
         )

Kantis avatar Oct 13 '21 20:10 Kantis