talira

Ruby's JSON parser and generator, shipped with Ruby as a default gem

open sourceRuby OR BSD-2-Clausefree

json is the JSON implementation for Ruby: JSON.parse turns a JSON document into Ruby hashes and arrays, and JSON.generate and JSON.pretty_generate turn Ruby data back into UTF-8 JSON, following RFC 7159. Objects without a JSON equivalent are serialized through their to_json methods, or through a JSON::Coder that decides how each type is written in one place. It's a C extension on CRuby, with a Java extension for JRuby, and it ships with Ruby as a default gem, maintained by members of the Ruby core team; installing the gem gets a newer version than the one Ruby bundles.

Problems it solves

  • parse a JSON string into a Ruby hash
  • turn Ruby objects into JSON with custom rules for dates and other types
  • pretty-print JSON from a Ruby script

Features

  • JSON.parse and JSON.generate
  • pretty_generate for indented output
  • JSON::Coder for per-call serialization of custom types
  • ascii_only output with \u escapes
  • C extension for CRuby and Java extension for JRuby

Alternatives

The same job

These do what json does.

  1. Oj A fast JSON parser and Object marshaller as a Ruby gem

Compare json with the top 3