Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Parses a JSON file containing multiple objects that are not contained in a single object.

View parse_json_multi_records.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14
require 'yajl'
 
def parse(json_filespec)
json_file = File.new(json_filespec, 'r')
parser = Yajl::Parser.new
records = []
parser.parse(json_file) do |x|
records << x
end
records
end
 
all_records_in_file = parse 'test.json'
puts "Found #{all_records_in_file.size} records."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.