Sha256: e57be09e968712e616eb8e9a32628a97d890f8450f03443b79531c91a527de60

Contents?: true

Size: 1.14 KB

Versions: 117

Compression:

Stored size: 1.14 KB

Contents

framework 'Foundation'
require 'multi_json/adapters/ok_json'

module MultiJson
  module Adapters
    class Nsjsonserialization < MultiJson::Adapters::OkJson
      ParseError = ::MultiJson::OkJson::Error

      def load(string, options={})
        string = string.read if string.respond_to?(:read)
        data = string.dataUsingEncoding(NSUTF8StringEncoding)
        object = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves, error: nil)
        if object
          object = symbolize_keys(object) if options[:symbolize_keys]
          object
        else
          super(string, options={})
        end
      end

      def dump(object, options={})
        pretty = options[:pretty] ? NSJSONWritingPrettyPrinted : 0
        object = object.as_json if object.respond_to?(:as_json)
        if NSJSONSerialization.isValidJSONObject(object)
          data = NSJSONSerialization.dataWithJSONObject(object, options: pretty, error: nil)
          NSMutableString.alloc.initWithData(data, encoding: NSUTF8StringEncoding)
        else
          super(object, options)
        end
      end

    end
  end
end

Version data entries

117 entries across 108 versions & 14 rubygems

Version Path
scout-5.9.13 vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb
scout-5.9.12 vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb
scout-5.9.11 vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
scout-5.9.10.pre vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb
scout-5.9.8 vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.8/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
apl-library-0.0.90 vendor/bundle/ruby/1.8/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/multi_json-1.10.1/lib/multi_json/adapters/nsjsonserialization.rb
scout-5.9.7.2.pre vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb
scout-5.9.8.pre vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb
scout-5.9.7.1 vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb
scout-5.9.7.pre vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/gems/multi_json-1.7.9/lib/multi_json/adapters/nsjsonserialization.rb