Sha256: 44072f974b22555129dc4a30582c497f55c9adc1a32014489893ad9d68aaab08

Contents?: true

Size: 402 Bytes

Versions: 9

Compression:

Stored size: 402 Bytes

Contents

# Add a formatter to grape that converts all snake case hash keys from ruby to camel case.
module IntrospectiveGrape
  module Formatter
    module CamelJson
      def self.call(object, _env)
        if object.respond_to?(:to_json)
          JSON.parse(object.to_json).with_camel_keys.to_json
        else
          MultiJson.dump(object).with_camel_keys.to_json
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
introspective_grape-0.2.8 lib/introspective_grape/formatter/camel_json.rb
introspective_grape-0.2.7 lib/introspective_grape/formatter/camel_json.rb
introspective_grape-0.2.6 lib/introspective_grape/formatter/camel_json.rb
introspective_grape-0.2.5 lib/introspective_grape/formatter/camel_json.rb
introspective_grape-0.2.4 lib/introspective_grape/formatter/camel_json.rb
introspective_grape-0.2.3 lib/introspective_grape/formatter/camel_json.rb
introspective_grape-0.2.2 lib/introspective_grape/formatter/camel_json.rb
introspective_grape-0.2.0 lib/introspective_grape/formatter/camel_json.rb
introspective_grape-0.1.9 lib/introspective_grape/formatter/camel_json.rb