title: android-kotlin JsonObject JsonArray send request data via POST
body: <p>I want to send data request via post to server I want to know How can I add data in array</p>
  <pre><code>data class City(
     @SerializedName(&quot;cityId&quot;)
     val cityId: Int?,
     @SerializedName(&quot;detail&quot;)
     val detail: List&lt;String?&gt;
  )
  </code></pre>
  <p>Request</p>
  <pre><code>data class CityRequest(
     @SerializedName(&quot;listCity&quot;)
     val listCity: List&lt;City?&gt;
  )
  </code></pre>
  <p>Response</p>
  <pre><code>data class CityResponse(
     @SerializedName(&quot;code&quot;)
     val code: String?,
     @SerializedName(&quot;status&quot;)
     val status: Boolean?,
     @SerializedName(&quot;message&quot;)
     val message: String?
  )
  </code></pre>
  <p>API Server</p>
  <pre><code>@Headers(&quot;Content-Type: application/json&quot;)
  @POST(&quot;city&quot;)
  suspend fun sendCityContent(@Body listCity: CityRequest?): 
  Call&lt;CityResponse?&gt;
  </code></pre>
  <p>Connect Service
  I don't know how I can add information to this section in question.</p>
  <pre><code>private suspend fun sendDataCity(city: List&lt;city?&gt;) {
      val retrofit = clientCity
      val sendDataToServer = retrofit?.create(CityService::class.java)
      val call = sendDataToServer?.sendCityContent(CityRequest(city))
      call?.enqueue(object : Callback&lt;CityResponse?&gt; {
          override fun onResponse(
              call: Call&lt;CityResponse?&gt;, response: Response&lt;CityResponse?&gt;) {
              val getResponse = response.body()
              Timber.tag(&quot;SALE_CITY: &quot;).d(&quot;code: %s&quot;, getResponse?.code)
              Timber.tag(&quot;SALE_CITY: &quot;).d(&quot;status: %s&quot;, getResponse?.status)
              Timber.tag(&quot;SALE_CITY: &quot;).d(&quot;message: %s&quot;, getResponse?.message)
          }
  
          override fun onFailure(call: Call&lt;CityResponse?&gt;, t: Throwable?) {
              t?.printStackTrace()
          }
  
      })
  }
  </code></pre>
  <p>JSON Simple</p>
  <pre><code>{
  &quot;city&quot;: [
      {
          &quot;cityId&quot;: 1,
          &quot;answer&quot;: [
              &quot;1&quot;
          ]
      },
      {
          &quot;questionId&quot;: 2,
          &quot;answer&quot;: [
              &quot;2.1&quot;,
              &quot;2.2&quot;
          ]
      }
  ]}
  </code></pre>
  <p>What do I have to do next?
  Can you have a sample add data in array for me?
  Things I want</p>
  <pre><code>cityId = 1
  detail = &quot;1.1&quot;, &quot;1.2&quot;
  
  cityId = 2 
  detail = &quot;2.1&quot;, &quot;2.2&quot; 
  </code></pre>
  <p>thank you</p>