title: Spinner, key value and json in kotlin
body: <p>I'm receving some data from an <strong>API</strong> made with <strong>ACF</strong> and <strong>Wordpress</strong>. I'm parsing the json**,** then I display the result in my android (<strong>kotlin</strong>) application.</p>
  
  <p>But I'm stuck. I need to make a <strong><em>key/value</em></strong> system for my spinner. I'm using an ArrayList for the moment where I'm adding the index of the loop and the value of the loop. </p>
  
  <p>Then, I'm adding this to a spinner, but I'm only adding a value to this (value is what is showed on my app).</p>
  
  <p>See: </p>
  
  <pre><code>    private fun getMulti(array: JSONArray): ArrayList&lt;FormInput&gt;? {
      val arrayInputs: ArrayList&lt;FormInput&gt; = ArrayList()
  
      if (array.length() &gt; 0) {
          (0 until array.length()).forEach { j -&gt;
              val objInput = array.getJSONObject(j)
  
              val placeholder2 = objInput.getString(Constants.placeholder)
              val type = objInput.getString(Constants.type)
              val customtag = objInput.getString(Constants.customtag)
  
              val input = FormInput(null, placeholder2, type, customtag, null)
              if (type == Constants.select) {
                  val valuesArray = objInput.getJSONArray(Constants.values)
                  Log.i("valeur json : ", valuesArray.toString())
                  if (valuesArray.length() &gt; 0) {
                      (0 until valuesArray.length()).forEach {
                          val valeur = input.addItems(valuesArray.getJSONObject(it).getString(Constants.value))
                          if(valuesArray.getJSONObject(it).getString(Constants.prix).toString() != ""){
                              val item = valuesArray.getJSONObject(it).getString(Constants.prix).toString().toFloat()
                              keyValSpinner.add(j, item)
                          }
                      }
                      // On ajoute l'input seulement si il est valide
                      arrayInputs.add(input)
                  }
              } else {
                  arrayInputs.add(input)
              }
          }
          return arrayInputs
      } else {
          return null
      }
  }
  </code></pre>
  
  <p>This is my json</p>
  
  <pre><code>{
    "datas": [
      {
        "id": 472,
        "titre": "Escaliers",
        "order": "4",
        "inputs": [
          {
            "title": "Escaliers",
            "type": "multi",
            "placeholder": "",
            "display_alone": true,
            "values": false,
            "other": false,
            "inputs": [
              {
                "placeholder": "Modèle",
                "type": "select",
                "values": [
                  {
                    "value": "Droit",
                    "prix": ""
                  },
                  {
                    "value": "1/4 tournant 1 volée",
                    "prix": "2362.5"
                  },
                  {
                    "value": "1/4 tournant 2 volée",
                    "prix": ""
                  },
                  {
                    "value": "2/4 tournants",
                    "prix": ""
                  },
                  {
                    "value": "Demi-tour",
                    "prix": ""
                  }
                ],
                "customtag": "noTag"
              },
              {
                "placeholder": "Contremarches",
                "type": "select",
                "values": [
                  {
                    "value": "Avec contremarche",
                    "prix": "324"
                  },
                  {
                    "value": "Sans contremarche",
                    "prix": ""
                  }
                ],
                "customtag": "noTag"
              },
              {
                "placeholder": "ML garde-corps étage",
                "type": "switch",
                "values": false,
                "customtag": "garde_corps"
              }
            ],
            "custom_tag_alone": "noTagAlone"
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>My arrayList</p>
  
  <pre><code>class KeyValSpinner {
      companion object {
          val keyValSpinner : ArrayList&lt;Any&gt; = ArrayList&lt;Any&gt;()
  
      }
  }
  </code></pre>
  
  <p>For now I have my arrayList with index from 0 to 10 and some prices. But I need to get the value of each object of each spinner, so maybe to an arraylist of arraylist( this one where are stored the value ?) </p>
  
  <p>I've been strugguling for hours with this...</p>
  
  <p>How can I create key/value from this json for each item ? </p>
  
  <p>(PS : I can modify the api as I want)</p>