body format , that I want to send to rest api server :
            Asked
            
        
        
            Active
            
        
            Viewed 932 times
        
    1 Answers
0
            
            
        for sending nested json with retrofit , must use @Body annotation in api interface, for above JSON :
first make a data class for your hole JSON :
data class YourJSON (@SerializedName("data")
                      var data : String,
                    @SerializedName("data2")
                      var data2: Data2 ,
                    )
then make a data class for another object inside the JSON :
data class Data2 (@SerializedName("obj")
                  var obj: String,
                @SerializedName("obj1")
                  var obj1: String ,
                @SerializedName("obj2")
                  var obj2: String ,
                @SerializedName("obj3")
                  var obj3: Int
                )
then make an interface class :
interface ApiService {
@POST(/api/your/url)
  fun sendData(
    @Body  yourJson : YourJSON,
): Observable <yourResponse> }
 
    
    
        Ali Salehi
        
- 164
- 2
- 9
