How can I add an item to this json? this way I can receive it in the details activity to complete a url to access it.
[
{
"item1": "Finalizado",
"item2": "F"
}]
And my intention is to add "item3": "$ data" after "item2": "F" The $ data can be 1, 2, 3, which is a string which will be the value returned by the variable data and this is what I do:
val jorn = items.add(dato) // dato en rojo
val adapter = AdapJor(activity !!, jorn ) //jorn en rojo
private fun requestJsonObject() {
val queue = newRequestQueue(activity)
val url = Directions.JORNADAS + Directions.CMP + "&jor=$dato&tmp=" + Directions.TMP
val stringRequest = StringRequest(Request.Method.GET, url, Response.Listener { response ->
val builder = GsonBuilder()
val mGson = builder.create()
var items: List<ModelJor>
items = Arrays.asList(*mGson.fromJson(response, Array<ModelJor>::class.java))
val jorn = items.add(dato)
recyclerView !!.layoutManager = GridLayoutManager(activity!!, 1)
val adapter = AdapJor(activity !!, jorn )
recyclerView !!.adapter = adapter
}, Response.ErrorListener { error -> Log.d(TAG, "Error " + error.message) })
queue.add(stringRequest)
}