Created
September 25, 2012 13:36
-
-
Save themiurgo/3781917 to your computer and use it in GitHub Desktop.
Convert a one-line stream of JSON objects into a newline separated (multiline) stream
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
#/bin/bash | |
# Fix all the files and puts them in a 'fixed' subdirectory | |
mkdir fixed | |
for f in *.gz; do gunzip -c $f | ruby jsonsm.rb | gzip -c > fixed/$f; done |
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
require 'yajl' | |
Yajl::Parser.parse(STDIN) do |event| | |
print Yajl::Encoder.encode(event) | |
print "\n" | |
end |
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
require 'open-uri' | |
require 'zlib' | |
require 'yajl' | |
#gz = open('http://data.githubarchive.org/2012-03-11-12.json.gz') | |
js = Zlib::GzipReader.new(STDIN).read | |
Yajl::Parser.parse(js) do |event| | |
print Yajl::Encoder.encode(event) | |
print "\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment