This file contains 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/ruby | |
# This script acts as a command-line filter to convert a BSON file (such as from mongodump) to an equivalent JSON file | |
# The resulting JSON file will be an array of hashes | |
# Any binary values from the BSON file are converted to base64 (such as Mongo's _id fields) | |
# I originally wrote this script so that Mongo files can be easily used with jsawk for | |
# offline data processing -- https://github.com/micha/jsawk | |
# | |
# To invoke, assuming mycollection.bson is a file from mongodump: | |
# ruby bson2json.rb < mycollection.bson > mycollection.json |