Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 117 lines (89 sloc) 4.6 kb
514eb63 @sferik Switch up Markdown syntax for headers [ci skip]
sferik authored
1 # MultiJSON
d830026 @sferik Cleanup
sferik authored
2 Lots of Ruby libraries utilize JSON parsing in some form, and everyone has
3 their favorite JSON library. In order to best support multiple JSON parsers and
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
4 libraries, `multi_json` is a general-purpose swappable JSON backend library.
5 You use it like so:
d830026 @sferik Cleanup
sferik authored
6
7 require 'multi_json'
8
9 MultiJson.engine = :yajl
118acc7 @joshk minor readme change so I can trigger a new build
joshk authored
10 MultiJson.decode('{ "abc":"def" }') # decoded using Yajl
d830026 @sferik Cleanup
sferik authored
11
12 MultiJson.engine = :json_gem
13 MultiJson.engine = MultiJson::Engines::JsonGem # equivalent to previous line
118acc7 @joshk minor readme change so I can trigger a new build
joshk authored
14 MultiJson.encode({ :abc => 'def' }) # encoded using the JSON gem
d830026 @sferik Cleanup
sferik authored
15
dca0e50 @bsiggelkow Added doco for pretty encoding
bsiggelkow authored
16 MultiJson.encode({ :abc => 'def' }, :pretty => true) # encoded in a pretty form (ignored if engine is ok_json)
17
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
18 The `engine` setter takes either a symbol or a class (to allow for custom JSON
19 parsers) that responds to both `.decode` and `.encode` at the class level.
d830026 @sferik Cleanup
sferik authored
20
21 MultiJSON tries to have intelligent defaulting. That is, if you have any of the
22 supported engines already loaded, it will utilize them before attempting to
23 load any. When loading, libraries are ordered by speed. First Yajl-Ruby, then
24 the JSON gem, then JSON pure. If no JSON library is available, MultiJSON falls
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
25 back to a bundled version of [OkJson][].
26
27 [okjson]: https://github.com/kr/okjson
d830026 @sferik Cleanup
sferik authored
28
514eb63 @sferik Switch up Markdown syntax for headers [ci skip]
sferik authored
29 ## <a name="ci">Continuous Integration</a>
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
30 [![Build Status](https://secure.travis-ci.org/intridea/multi_json.png)][ci]
31
32 [ci]: http://travis-ci.org/intridea/multi_json
33
34 ## <a name="dependencies"></a>Dependency Status
35 [![Dependency Status](https://gemnasium.com/intridea/multi_json.png)][gemnasium]
36
37 [gemnasium]: https://gemnasium.com/intridea/multi_json
f3c325e @sferik Add link to Travis CI
sferik authored
38
514eb63 @sferik Switch up Markdown syntax for headers [ci skip]
sferik authored
39 ## <a name="contributing">Contributing</a>
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
40 In the spirit of [free software][free-sw], **everyone** is encouraged to help
41 improve this project.
42
43 [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
d830026 @sferik Cleanup
sferik authored
44
45 Here are some ways *you* can contribute:
46
47 * by using alpha, beta, and prerelease versions
48 * by reporting bugs
49 * by suggesting new features
50 * by writing or editing documentation
51 * by writing specifications
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
52 * by writing code (**no patch is too small**: fix typos, add comments, clean up
53 inconsistent whitespace)
d830026 @sferik Cleanup
sferik authored
54 * by refactoring code
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
55 * by closing [issues][]
d830026 @sferik Cleanup
sferik authored
56 * by reviewing patches
57
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
58 [issues]: https://github.com/intridea/multi_json/issues
59
514eb63 @sferik Switch up Markdown syntax for headers [ci skip]
sferik authored
60 ## <a name="issues">Submitting an Issue</a>
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
61 We use the [GitHub issue tracker][issues] to track bugs and features. Before
62 submitting a bug report or feature request, check to make sure it hasn't
63 already been submitted. You can indicate support for an existing issuse by
64 voting it up. When submitting a bug report, please include a [Gist][] that
65 includes a stack trace and any details that may be necessary to reproduce the
66 bug, including your gem version, Ruby version, and operating system. Ideally, a
67 bug report should include a pull request with failing specs.
68
69 [gist]: https://gist.github.com/
514eb63 @sferik Switch up Markdown syntax for headers [ci skip]
sferik authored
70
71 ## <a name="pulls">Submitting a Pull Request</a>
d830026 @sferik Cleanup
sferik authored
72 1. Fork the project.
73 2. Create a topic branch.
74 3. Implement your feature or bug fix.
75 4. Add specs for your feature or bug fix.
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
76 5. Run `bundle exec rake spec`. If your changes are not 100% covered, go back
77 to step 4.
d830026 @sferik Cleanup
sferik authored
78 6. Commit and push your changes.
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
79 7. Submit a pull request. Please do not include changes to the gemspec,
80 version, or history file. (If you want to create your own version for some
81 reason, please do so in a separate commit.)
d830026 @sferik Cleanup
sferik authored
82
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
83 ## <a name="versions">Supported Ruby Versions</a>
84 This library aims to support and is [tested against][ci] the following Ruby
d578eab @sferik Add section on Supported Rubies
sferik authored
85 implementations:
86
87 * Ruby 1.8.7
88 * Ruby 1.9.2
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
89 * Ruby 1.9.3
90 * [JRuby][]
91 * [Rubinius][]
92 * [Ruby Enterprise Edition][ree]
93
94 [jruby]: http://www.jruby.org/
95 [rubinius]: http://rubini.us/
96 [ree]: http://www.rubyenterpriseedition.com/
d578eab @sferik Add section on Supported Rubies
sferik authored
97
98 If something doesn't work on one of these interpreters, it should be considered
99 a bug.
100
101 This library may inadvertently work (or seem to work) on other Ruby
102 implementations, however support will only be provided for the versions listed
103 above.
104
105 If you would like this library to support another Ruby version, you may
106 volunteer to be a maintainer. Being a maintainer entails making sure all tests
107 run and pass on that implementation. When something breaks on your
108 implementation, you will be personally responsible for providing patches in a
109 timely fashion. If critical issues for a particular implementation exist at the
110 time of a major release, support for that Ruby version may be dropped.
111
514eb63 @sferik Switch up Markdown syntax for headers [ci skip]
sferik authored
112 ## <a name="copyright">Copyright</a>
d830026 @sferik Cleanup
sferik authored
113 Copyright (c) 2010 Michael Bleigh, Josh Kalderimis, Erik Michaels-Ober, and Intridea, Inc.
a1953a8 @sferik Add dependency status [ci skip]
sferik authored
114 See [LICENSE][] for details.
115
116 [license]: https://github.com/intridea/multi_json/blob/master/LICENSE.md
Something went wrong with that request. Please try again.