Sha256: d392fe24d3bfe7076bab2901c398b312d430a9a61987698ec16ea362369b23c0

Contents?: true

Size: 735 Bytes

Versions: 217

Compression:

Stored size: 735 Bytes

Contents

#!/usr/bin/env ruby -wW2

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

217 entries across 217 versions & 2 rubygems

Version Path
oj-3.10.7 test/sample_json.rb
oj-3.10.6 test/sample_json.rb
oj-3.10.5 test/sample_json.rb
oj-3.10.3 test/sample_json.rb
oj-3.10.2 test/sample_json.rb
oj-3.10.1 test/sample_json.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/oj-3.10.0/test/sample_json.rb
oj-3.10.0 test/sample_json.rb
oj-3.9.2 test/sample_json.rb
oj-3.9.1 test/sample_json.rb
oj-3.9.0 test/sample_json.rb
oj-3.8.1 test/sample_json.rb
oj-3.8.0 test/sample_json.rb
oj-3.7.12 test/sample_json.rb
oj-3.7.11 test/sample_json.rb
oj-3.7.10 test/sample_json.rb
oj-3.7.9 test/sample_json.rb
oj-3.7.8 test/sample_json.rb
oj-3.7.7 test/sample_json.rb
oj-3.7.6 test/sample_json.rb