Я пытаюсь извлечь JSON
из списка GitHub, используя кодирование в Kotlin. Я получаю ответ как
E/tag: Response{protocol=http/1.1, code=200, message=OK, url=https://api.github.com/gists/02d3e6e910739c35fc7d14b3fd16466a}
Я хочу получить json
в ответе.
Вот как я назвал URL-адрес дис-кодом для моего MainActivity
private val retrofit= Retrofit.Builder().baseUrl("https://api.github.com/")
.addConverterFactory(GsonConverterFactory.create())
.build()
private val postsApi = retrofit.create(RequestApi::class.java)
private val response= postsApi.getAllData()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
response.enqueue(object: Callback<NewResponse>{
override fun onFailure(call: Call<NewResponse>, t: Throwable) {
//To change body of created functions use File | Settings | File Templates.
}
override fun onResponse(call: Call<NewResponse>, response: Response<NewResponse>) {
//To change body of created functions use File | Settings | File Templates.
val mResponse= response.raw().toString()
Log.e("tag", mResponse)
}
})
}
Код моего запроса
interface RequestApi {
@GET("gists/02d3e6e910739c35fc7d14b3fd16466a")
fun getAllData(): Call<NewResponse>
}
Мой класс CVResponse
class CVResponse {
@SerializedName("data")
val data: Data? = null
}
Я хочу получить JSON, как показано ниже
{
"data":{
"name":"Maria",
"summary":"Likable and dedicated IT consultant with over 5 years of experience in a fast-paced fin-tech company. Eager to offer superb analytical and computer skills to help ABC Inc grow its client base. In previous roles recognized for top company-wide quality satisfaction rating.",
"skills":[
{
"type":"Design Languages",
"languages":[
"HTML",
"XML",
"CSS"
]
},
{
"type":"Language",
"languages":[
"Java",
"C#",
"C++",
"Kotlin"
]
},
{
"type":"Scripting Language",
"languages":[
"Javascript"
]
},
{
"type":"Server Language",
"languages":[
"Php"
]
},
{
"type":"Operating System",
"languages":[
"Windows",
"Mac",
"Android"
]
},
{
"type":"Database",
"languages":[
"Sqlite",
"SQL",
"MySQL"
]
},
{
"type":"Frameworks",
"languages":[
"Netbeans",
"Eclipse",
"ADT-Bundle"
]
}
],
"education_bg":[
{
"position":"Post-Graduate in IBM",
"Major":"International Business",
"from":"2018",
"to":"2019",
"institute_name":"Douglas College"
},
{
"position":"Post-Graduate in ICT",
"Major":"Information Technology",
"from":"2017",
"to":"2018",
"institute_name":"Douglas College"
},
{
"position":"Bachelors in CSE",
"Major":"Computer Science",
"from":"2010",
"to":"2014",
"institute_name":"Douglas College"
}
]
}
}