TeamCity API reposnse to kotlin object

I am consuming TeamCity API in kotlin, how can I convert xml or json to a kotlin class?

In C# I would use something like EasyHttp.Http that can return the body of the response as dynamic, and wrap that dynamic object with C# class.

10x,
Alex

Hi Alex,

We don’t have dynamic in Kotlin so unfortunately that’s not really possible the way I did in EasyHttp. However, I’m working on a port of EasyHttp to Kotlin (https://github.com/hhariri/easyhttpjvm) and I’m playing with the idea of doing things like this:

val name = response[“customer.name”]

(more or less, not exact syntax).

The code however doesn’t support SSL yet and I wouldn’t say it’s production ready.

In the meantime, my suggestion would be to either create data classes if you want static typing and use Jackson or Gson to map to these. Or alternatively map it out to a dictionary if you want to avoid the overhead of intermediary classes.

10x. For now will go with Jackson and keep an eye on EasyHttpJvm.