Am using kotlin for developing the application.Now i want to get JSON data from server.
In java am implemented Asyntask as well as Rxjava for read JSON from Url . Am also search in google but i cant get proper details for my requirement.
How can i read JSON from Url using kotlin?
Finally am getting answer from Here
Read Json data using Retrofit 2.0 RxJava, RxAndroid, Kotlin Android Extensions.
fun provideRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl("https://www.example.com")
.addConverterFactory(MoshiConverterFactory.create())
.build()
}
Module
interface Api {
@GET("/top.json")
fun getTop(@Query("after") after: String,
@Query("limit") limit: String): Call<NewsResponse>;
}