title: rails 4 JSON::ParserError (757: unexpected token at 'null'):
body: <p>I am having the following method in my controller</p>
  
  <pre><code>@content = Post.where(sub_category_id: id).select('content')
  unless @content.nil?
        @content.each do |content|
          form_array = JSON.parse(content.content)
          array_test &lt;&lt; form_array.values
        end
  </code></pre>
  
  <p>My content column has the value as <code>null</code> so I am getting error as</p>
  
  <pre><code>JSON::ParserError (757: unexpected token at 'null'):
  </code></pre>
  
  <p>But why the unless loop is not working. The loop gets executed when the column has <code>null</code> value how to prevent it</p>
  
  <p><strong>Edit-1</strong></p>
  
  <p>Consider I have two rows in my database table</p>
  
  <p>one is <code>{"Style":"coupe","Year":"2012","Color":"green"}</code> #This works fine</p>
  
  <p>second is <code>null</code> #But this fails</p>