I'm building a little client application with Ktor...
# serialization
t
I'm building a little client application with Ktor accessing a Third-Party-API. The API give a response with the following part
Copy code
fullsize_url: "https://...."
image_url: "https://...."
In my Data Class these should be represented by specific URL Types. Which one should i use java.net.URL or io.ktor.http.Url ? Is there a ready to use Serializer for any of those both?
a
I think there's a ready-to-use serializer for URLs in https://github.com/Kantis/ks3
Copy code
@file:UseSerializers(
  UrlSerializer::class,
  FooSerializer::class,
  BarSerializer::class,
  // ...
)
you could also consider using typealiases
Copy code
typealias UrlSerialized = @Serialized(with = UrlSerializer::class) URL
that would save having to copy-paste the
@file:UserSerializers()
in multiple files
e
I think there is a typealias included :)
UrlAsString
, unless it was added after 0.0.2