Sha256: 1bdb794b6361ca59aaaf3b474171361582a9a9db6419bad266e9b8f112c29337

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 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={})
        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

12 entries across 12 versions & 7 rubygems

Version Path
able-neo4j-1.0.0 vendor/bundle/jruby/1.9/gems/multi_json-1.11.2/lib/multi_json/adapters/nsjsonserialization.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/multi_json-1.11.2/lib/multi_json/adapters/nsjsonserialization.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/multi_json-1.11.2/lib/multi_json/adapters/nsjsonserialization.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/multi_json-1.11.2/lib/multi_json/adapters/nsjsonserialization.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/multi_json-1.11.2/lib/multi_json/adapters/nsjsonserialization.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/multi_json-1.11.2/lib/multi_json/adapters/nsjsonserialization.rb
multi_json-1.11.2 lib/multi_json/adapters/nsjsonserialization.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/multi_json-1.11.1/lib/multi_json/adapters/nsjsonserialization.rb
multi_json-1.11.1 lib/multi_json/adapters/nsjsonserialization.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/multi_json-1.11.0/lib/multi_json/adapters/nsjsonserialization.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/multi_json-1.11.0/lib/multi_json/adapters/nsjsonserialization.rb
multi_json-1.11.0 lib/multi_json/adapters/nsjsonserialization.rb