Elster
Elster is a streaming JSON encoder written in pure ruby.
Installation
Add this line to your application's Gemfile:
gem 'elster'
And then execute:
$ bundle
Or install it yourself as:
$ gem install elster
Usage
output = StringIO.new
json = Elster::Streamer.new(output)
json.key(:name, "George")
json.key(:kids) do
json.add("Job")
json.add("Buster")
end
json.close
puts output.string
# {"name":"George","kids":["Job","Buster"]}
With Rails
You can use Elster with rails by naming templates with the .json.elster
extension. When used as a rails template simply reference the implicit json
object. For example:
json.key(:name, "George")
json.key(:kids) do
json.add("Job")
json.add("Buster")
end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request