Created
July 25, 2013 20:42
-
-
Save parrish/6083571 to your computer and use it in GitHub Desktop.
Convert BSON to a valid JSON document
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 | |
data = `bsondump #{ ARGV[0] }`.chomp | |
data.gsub! /ObjectId\(\s?(\"\w+\")\s?\)/, '\1' | |
data.gsub! /Date\(\s?(\w+)\s?\)/, '\1' | |
data = data.split "\n" | |
data = "[#{ data.join(', ') }]" | |
File.open(ARGV[1], 'w') do |f| | |
f.puts data | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment