Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert a one-line stream of JSON objects into a newline separated (multiline) stream
#/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
require 'yajl'
Yajl::Parser.parse(STDIN) do |event|
print Yajl::Encoder.encode(event)
print "\n"
end
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
You can’t perform that action at this time.