Created
October 9, 2015 08:08
-
-
Save gousiosg/26177bb7cd1ab8a76eeb to your computer and use it in GitHub Desktop.
Convert JSON to BSON for importing into MongoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'json' | |
require 'bson' # Requires bson version > 3 | |
json = JSON.parse(File.open(ARGV[0]).read) | |
w = File.open("#{ARGV[0]}.bson",'w') | |
json.each do |j| | |
w.write(j.to_bson) | |
end | |
w.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment