title: Decoding unnamed JSON array swift 4 with structure
body: <p>I have been trying to decode an array for an app where I have to decode JSON.</p>
  <p>I just can't decode it with my actual structure and others which I tried before.</p>
  <p>Here are my latest structures:</p>
  <pre><code>struct peticion: Decodable{
      let datos_conexion: datos_conexion
      let estado_lanzamiento: estado_lanzamiento
      let usuario: usuario
  }
  
  struct datos_conexion: Decodable {
      let conexion: datosConexion
  }
  
  struct datosConexion: Decodable{
      let datos_conexion: String
  }
  
  struct estado_lanzamiento: Decodable{
      let tiempo_restante: String
      let etapa_actual: String
  }
  
  struct usuario: Decodable {
      let Id: Int
      let Nombre: String
      let Password: String
      let Imagen: String
      let Puesto: String
      let Departamento: String
  }
  </code></pre>
  <p>JSON full example from Request</p>
  <pre><code>[
      {
          &quot;datos_conexion&quot;: {
              &quot;conexion&quot;: &quot;2019-05-27 17:05:45&quot;
          }
      },
      {
          &quot;estado_lanzamiento&quot;: {
              &quot;tiempo_restante&quot;: 240,
              &quot;etapa_actual&quot;: &quot;Configuracion&quot;
          }
      },
      {
          &quot;usuario&quot;: [
              {
                  &quot;Id&quot;: &quot;4&quot;,
                  &quot;Nombre&quot;: &quot;This is the Name&quot;,
                  &quot;Email&quot;: &quot;email@gmail.com&quot;,
                  &quot;Password&quot;: &quot;1234&quot;,
                  &quot;Imagen&quot;: &quot;default.jpg&quot;,
                  &quot;Puesto&quot;: &quot;&quot;,
                  &quot;Departamento&quot;: &quot;Etapa Final&quot;
              }
          ]
      }
  ]
  </code></pre>
  <p>decoding code</p>
  <pre><code>URLSession.shared.dataTask(with: url2) { (data, resp, err) in
      guard let data = data else{return}
      let dataAsString = String(data: data, encoding: .utf8)
  //      print(dataAsString)
      do {
          let JSONDATA = try JSONDecoder().decode([peticion].self, from: data)
  //     print(data)
      } catch let jsonErr {
          print(&quot;cant decode&quot;, jsonErr)
      }
  </code></pre>
  <p>Errors trying to do this:</p>
  <blockquote>
  <p>typeMismatch(Swift.Array, Swift.DecodingError.Context(codingPath: [], debugDescription: &quot;Expected to decode Array but found a dictionary instead.&quot;, underlyingError: nil))</p>
  <p>typeMismatch(Swift.Array, Swift.DecodingError.Context(codingPath: [], debugDescription: &quot;Expected to decode dictionary but found an Array instead.&quot;, underlyingError: nil))</p>
  </blockquote>