
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.
19 lines
436 B
Ruby
19 lines
436 B
Ruby
require 'yajl' unless defined?(Yajl)
|
|
|
|
module MultiJson
|
|
module Engines
|
|
# Use the Yajl-Ruby library to encode/decode.
|
|
class Yajl
|
|
ParseError = ::Yajl::ParseError
|
|
|
|
def self.decode(string, options = {}) #:nodoc:
|
|
::Yajl::Parser.new(:symbolize_keys => options[:symbolize_keys]).parse(string)
|
|
end
|
|
|
|
def self.encode(object) #:nodoc:
|
|
::Yajl::Encoder.new.encode(object)
|
|
end
|
|
end
|
|
end
|
|
end
|