Kotlin解析json数据

背景

kotlin,解析okhttp返回得数据

方法

class ResCode (public  val obj:JsonObject){
    var status:Int ?=-1
    var msg:String ?=""
}
 fun parseJsonWithJsonObject(response:Response){
        result=  response.body?.string().toString()
        var resCode=Gson().fromJson(result,ResCode::class.java)
        println(resCode.status)
        println(resCode.msg)
    }

你可能感兴趣的:(kotlin,json,kotlin,java)