title: How to create objects from JSON in Rails
body: <p>I have a controller which is used to parse a site.  From that parsing, I get a JSON object.  In that JSON object I have mainly two things: prices and images.</p>
  
  <p>So, a Page has many Price and Image.  First thing I do when creating the controller is:</p>
  
  <pre><code>@page = Page.create(:url =&gt; parsed_url)
  </code></pre>
  
  <p>Then from the @output, I want to be able to create several @images and @prices.  So, I do this:</p>
  
  <pre><code>@prices = @output["prices"]
  @images = @output["images"]
  </code></pre>
  
  <p>So, <code>@images</code> look like <code>[{:width =&gt; 12, :height =&gt; 13, :src =&gt; 'http...'}, {:width =&gt; 20,..}]</code></p>
  
  <p>I want to create an Image associated with that <code>@page</code> for each object in the array. Before doing that though I might need to check those attributes (width, height) and manipulate them before inserting them to the DB. So my question is... Where and how should I do this?</p>
  
  <p>I know how to create an Image by doing <code>Image.create(:page_id =&gt; @page.id, :width =&gt; 12...)</code>, but how do I do that form that JSON response that needs to be treated first?</p>