Search code examples
javaandroidjsonkotlinretrofit

How to segregate json data in kotlin


I have getting response following json format. I need to message value only. how to segregate the message value. can you please help me.

{status:"1", message:"cu34343"}

Solution

  • if response as object

    val jsonObject = JSONTokener(response).nextValue() as JSONObject
    val message = jsonObject.getString("message")// Before That check null or 
    not
    Log.i("message: ", message)
    

    also refer different response using gson and response model class converter.