Charlie Sharpsteen 1d1cd374b3 Vendor Library: multi-json 1.0.3
Multi-JSON is a library that provides encode/decode support for casting Ruby
objects to JSON strings and back again. This version of the library has been
tested against ruby versions 1.8.6 and later.

Having a JSON encoder/decoder in the toolbox helps now that the GitHub API only
returns results in JSON format.
2011-11-13 12:14:55 -08:00

22 lines
499 B
Ruby

require 'json/pure' unless defined?(::JSON)
module MultiJson
module Engines
# Use JSON pure to encode/decode.
class JsonPure
ParseError = ::JSON::ParserError
def self.decode(string, options = {}) #:nodoc:
opts = {}
opts[:symbolize_names] = options[:symbolize_keys]
string = string.read if string.respond_to?(:read)
::JSON.parse(string, opts)
end
def self.encode(object) #:nodoc:
object.to_json
end
end
end
end