Skip to content


Subversion checkout URL

You can clone with
Download ZIP
100644 67 lines (54 sloc) 3.054 kB
d830026 @sferik Cleanup
sferik authored
1 MultiJSON
2 =========
4 Lots of Ruby libraries utilize JSON parsing in some form, and everyone has
5 their favorite JSON library. In order to best support multiple JSON parsers and
6 libraries, <tt>multi_json</tt> is a general-purpose swappable JSON backend
7 library. You use it like so:
9 require 'multi_json'
11 MultiJson.engine = :yajl
12 MultiJson.decode('{"abc":"def"}') # decoded using Yajl
14 MultiJson.engine = :json_gem
15 MultiJson.engine = MultiJson::Engines::JsonGem # equivalent to previous line
16 MultiJson.encode({:abc => 'def'}) # encoded using the JSON gem
18 The <tt>engine</tt> setter takes either a symbol or a class (to allow for
19 custom JSON parsers) that responds to both <tt>.decode</tt> and
20 <tt>.encode</tt> at the class level.
22 MultiJSON tries to have intelligent defaulting. That is, if you have any of the
23 supported engines already loaded, it will utilize them before attempting to
24 load any. When loading, libraries are ordered by speed. First Yajl-Ruby, then
25 the JSON gem, then JSON pure. If no JSON library is available, MultiJSON falls
26 back to a bundled version of [OkJson](
28 Contributing
29 ------------
30 In the spirit of [free software](, **everyone** is encouraged to help improve this project.
32 Here are some ways *you* can contribute:
34 * by using alpha, beta, and prerelease versions
35 * by reporting bugs
36 * by suggesting new features
37 * by writing or editing documentation
38 * by writing specifications
39 * by writing code (**no patch is too small**: fix typos, add comments, clean up inconsistent whitespace)
40 * by refactoring code
41 * by closing [issues](
42 * by reviewing patches
44 Submitting an Issue
45 -------------------
46 We use the [GitHub issue tracker]( to track bugs and
47 features. Before submitting a bug report or feature request, check to make sure it hasn't already
48 been submitted. You can indicate support for an existing issuse by voting it up. When submitting a
49 bug report, please include a [Gist]( that includes a stack trace and any
50 details that may be necessary to reproduce the bug, including your gem version, Ruby version, and
51 operating system. Ideally, a bug report should include a pull request with failing specs.
53 Submitting a Pull Request
54 -------------------------
55 1. Fork the project.
56 2. Create a topic branch.
57 3. Implement your feature or bug fix.
58 4. Add specs for your feature or bug fix.
59 5. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 4.
60 6. Commit and push your changes.
61 7. Submit a pull request. Please do not include changes to the gemspec, version, or history file. (If you want to create your own version for some reason, please do so in a separate commit.)
63 Copyright
64 ---------
65 Copyright (c) 2010 Michael Bleigh, Josh Kalderimis, Erik Michaels-Ober, and Intridea, Inc.
66 See [LICENSE]( for details.
Something went wrong with that request. Please try again.