Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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