title: How to parse an image from JSON into swift4
body: <p>I am trying to pull images from my database in swift. I can retrieve the price, video, and p_name but not the images. I would like to update the updateImage <code>UIImageView</code> with the image from the database but I get two errors. </p>
  
  <p>Error one says:</p>
  
  <blockquote>
    <p>Type 'ViewController.Class' does not conform to protocol 'Encodable'</p>
  </blockquote>
  
  <p>Error two says:</p>
  
  <blockquote>
    <p>Type 'ViewController.Class' does not conform to protocol 'Dec</p>
  </blockquote>
  
  <p>What are some good work-arounds for this?</p>
  
  <p>Here is the JSON:</p>
  
  <pre><code>{
  "id":"1",
  "p_name":"item_one",
  "image":"item_one.png"
  }
  {
  "id":"2","p_name":
  "item_two","image":
  "item_two.img"
  }
  </code></pre>
  
  <p>And the swift code:</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
  @IBOutlet weak var updateLabel: UILabel!
  
  @IBOutlet weak var updateImage: UILabel!
  
  struct Class: Codable
  {
      let id: String
      let p_name: String
      let image: String
  
  }
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  
      let url = URL(string: "http://host-2:8888//getClasses.php")
  
      // Load the URL
      URLSession.shared.dataTask(with: url!, completionHandler: {(data, response, error) in
          // If there are any errors don't try to parse it, show the error
          guard let data = data, error == nil else { print(error!); return }
  
          let decoder = JSONDecoder()
          let classes = try! decoder.decode([Class].self, from: data)
          // Print out the classes to the console - try sticking this in a table view :)
          for myClass in classes {
  
              self.updateLabel.text = myClass.p_name
              self.updateImage.text = myClass.image
  
          }
  
      }).resume()
  
      }
  }
  </code></pre>