File: oj.rb

package info (click to toggle)
ruby-multi-json 1.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 180 kB
  • sloc: ruby: 845; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 583 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'oj' unless defined?(::Oj)

module MultiJson
  module Adapters
    # Use the Oj library to dump/load.
    class Oj
      ParseError = SyntaxError

      ::Oj.default_options = {:mode => :compat}

      def self.load(string, options={}) #:nodoc:
        options.merge!(:symbol_keys => options[:symbolize_keys] || options['symbolize_keys'])
        ::Oj.load(string, options)
      end

      def self.dump(object, options={}) #:nodoc:
        options.merge!(:indent => 2) if options[:pretty] || options['pretty']
        ::Oj.dump(object, options)
      end
    end
  end
end