如何在rails中创建有效的JSON对象,不使用散列火箭或转义引号

时间:2014-08-28 22:36:43

标签: ruby-on-rails json

这是我想要做的事情:

  new_set = set.map do |d|
    { id: d.id, first_name: d.firstname, last_name: d.lastname, full_name: d.full_name, score: d.score, photo: d.user.avatar(:medium), sex: d.sex, bio: d.bio, google_plus: d.google_plus, facebook: d.facebook, protocol: d.protocol, verified: d.verified, excellence: d.excellence, verified_at: d.verified_at, excellence_at: d.excellence_at, protocol_at: d.protocol_at, educations: d.educations, qualifications: d.qualifications, services: d.services, branches: d.branches, reviews: d.dispenser_reviews.where(:approved=>true) }
  end

现在,当我尝试new_set.to_json时,我会获得逃避报价。

当我跑new_set.as_json时,我会得到哈希火箭。

有没有办法获得有效的JSON,包括上面new_set中的信息?

0 个答案:

没有答案