Sha256: 97f57c2d27f506a924e7688daf7d1baf7f312a71762c0bee68c6021aabc872d4

Contents?: true

Size: 884 Bytes

Versions: 2

Compression:

Stored size: 884 Bytes

Contents

$:.push File.expand_path("../lib", __FILE__)
require 'argonaut'

@ideas = [
  {
    :title => 'Garrett Bjerkhoel',
    :comments => [
      {
        :id     => 1,
        :author => 'Jake',
        :text   => 'Sweet',
        :created_at => Time.now,
        :updated_at => Time.now
      },
      {
        :id     => 2,
        :author => 'Jake',
        :text   => nil,
        :created_at => Time.now,
        :updated_at => Time.now
      }
    ]
  }
]


json = Argonaut::Generator.new do |doc|
  doc.array_keys! ['ideas']
  for idea in @ideas
    doc.ideas do |i|
      i.title idea[:title]
      for comment in idea[:comments]
        i.comments do |c|
          c.id comment[:id]
          c.author comment[:author]
          c.text comment[:text]
          c.created_at comment[:created_at]
          c.updated_at comment[:updated_at]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
argonaut-0.0.2 examples.rb
argonaut-0.0.1 examples.rb