title: How to use ActiveModel::Serializer with a PostgreSQL JSON column
body: <p>I am trying to use <a href="https://github.com/rails-api/active_model_serializers" rel="nofollow">ActiveModel::Serializer</a> in conjunction with a PostgreSQL database.</p>
  
  <p>The problem I am having is that whenever I include a <code>json</code> type column in a serializer I get:</p>
  
  <pre><code>SystemStackError (stack level too deep):
    actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:70
  </code></pre>
  
  <p>I don't want to do <a href="http://reefpoints.dockyard.com/2014/05/27/avoid-rails-when-generating-json-responses-with-postgresql.html" rel="nofollow">this</a> as I need access to the data before returning it.</p>
  
  <p>From <code>schema.rb</code>:</p>
  
  <pre><code>create_table "jobs", force: true do |t|
      t.integer  "user_id"
      t.string   "tool"
      t.string   "name"
      t.json     "options"
      t.integer  "status"
      t.string   "version"
      t.datetime "created_at"
      t.datetime "updated_at"
  end
  </code></pre>
  
  <p><code>job_serializer.rb</code>:</p>
  
  <pre><code>class JobSerializer &lt; ApplicationSerializer
      attributes :id, :tool, :name, :status, :options, :version, :created_at
  
      has_many :inputs, serializer: FileLinkSerializer
  end
  </code></pre>
  
  <p>Works fine if I remove <code>:options</code> from the attributes but crashes when it is included as above.</p>