Sha256: ab7670da178d2b04b9c2626d5a9d22949ff3083c8aad39902a243be81dc0d43b

Contents?: true

Size: 730 Bytes

Versions: 52

Compression:

Stored size: 730 Bytes

Contents

#!/usr/bin/env ruby

if $0 == __FILE__
  $: << '.'
  $: << '..'
  $: << '../lib'
  $: << '../ext'
end

require 'pp'
require 'oj'

def sample_json(size=3)
  colors = [ :black, :gray, :white, :red, :blue, :yellow, :green, :purple, :orange ]
  container = []
  size.times do |i|
    box = {
      'color' => colors[i % colors.size],
      'fragile' => (0 == (i % 2)),
      'width' => i,
      'height' => i,
      'depth' => i,
      'weight' => i * 1.3,
      'address' => {
        'street' => "#{i} Main Street",
        'city' => 'Sity',
        'state' => nil
      }
    }
    container << box
  end
  container
end

if $0 == __FILE__
  File.open('sample.json', "w") { |f| f.write(Oj.dump(sample_json(3), :indent => 2)) }
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
devcycle-ruby-server-sdk-2.0.0 vendor/bundle/ruby/3.0.0/gems/oj-3.13.2/test/sample_json.rb
oj-3.14.2 test/sample_json.rb
oj-3.14.1 test/sample_json.rb
oj-3.14.0 test/sample_json.rb
oj-3.13.23 test/sample_json.rb
oj-3.13.22 test/sample_json.rb
oj-3.13.21 test/sample_json.rb
oj-3.13.20 test/sample_json.rb
oj-3.13.19 test/sample_json.rb
oj-3.13.18 test/sample_json.rb
oj-3.13.17 test/sample_json.rb
oj-3.13.16 test/sample_json.rb
oj-3.13.15 test/sample_json.rb
oj-3.13.14 test/sample_json.rb
oj-3.13.13 test/sample_json.rb
oj-3.13.12 test/sample_json.rb
oj-3.13.11 test/sample_json.rb
oj-3.13.10 test/sample_json.rb
oj-3.13.9 test/sample_json.rb
oj-3.13.8 test/sample_json.rb