Sha256: b8abc3a9ef57be603b5949a8c4b17b2b4ba2118f757c7f84f17d9332f5b25176

Contents?: true

Size: 781 Bytes

Versions: 10

Compression:

Stored size: 781 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

if $PROGRAM_NAME == __FILE__
  $LOAD_PATH << '.'
  $LOAD_PATH << '..'
  $LOAD_PATH << '../lib'
  $LOAD_PATH << '../ext'
end

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 $PROGRAM_NAME == __FILE__
  File.write('sample.json', Oj.dump(sample_json(3), :indent => 2))
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
oj-3.16.7 test/sample_json.rb
oj-3.16.6 test/sample_json.rb
oj-3.16.5 test/sample_json.rb
oj-3.16.4 test/sample_json.rb
oj-3.16.3 test/sample_json.rb
oj-3.16.2 test/sample_json.rb
oj-3.16.1 test/sample_json.rb
oj-3.16.0 test/sample_json.rb
oj-3.15.1 test/sample_json.rb
oj-3.15.0 test/sample_json.rb