talira

MultiJSON

One JSON interface for Ruby that picks the fastest available coder

open sourceMITfree

MultiJSON gives Ruby libraries one interface for JSON instead of tying them to a single coder: it uses the fastest JSON library available in the app (such as Oj, fast_jsonparser or the json gem), and you can pick an adapter yourself or write a custom one. Its parse and generate methods match Ruby's standard JSON module, parse errors come back as one error class with the line and column where the adapter reports them, and blank input parses to nil.

Problems it solves

  • let users of my Ruby gem choose their own JSON library
  • use Oj when it is installed and fall back to the json gem otherwise
  • switch a Ruby app's JSON parser without changing code that calls it

Features

  • one JSON API over several Ruby JSON coders
  • picks the fastest available coder
  • custom adapters
  • parse errors with line and column where the adapter reports them

Alternatives

The same job

These do what MultiJSON does.

  1. Oj A fast JSON parser and Object marshaller as a Ruby gem
  2. json Ruby's JSON parser and generator, shipped with Ruby as a default gem

Compare MultiJSON with the top 3