Skip to content

Commit a08f87a

Browse files
committed
deserialization would work now if it didn't depend on the existance of certain objects
1 parent 0fa5899 commit a08f87a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Gemfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ eval_gemfile local_gemfile if File.readable?(local_gemfile)
77
# Specify your gem's dependencies in active_model_serializers.gemspec
88
gemspec
99

10-
gem 'jsonapi-deserializable', github: 'beauby/jsonapi-deserializable'
11-
gem 'jsonapi-validations', github: 'beauby/jsonapi-validations'
1210
gem 'jsonapi', github: 'beauby/jsonapi'
11+
gem 'jsonapi-deserializable', github: 'beauby/jsonapi-deserializable', branch: 'new-dsl'
12+
gem 'jsonapi-validations', github: 'beauby/jsonapi-validations'
13+
gem 'jsonapi-rails', github: 'beauby/jsonapi-rails', branch: 'initial-implementation'
1314

1415
version = ENV['RAILS_VERSION'] || '4.2'
1516

lib/active_model_serializers/adapter/json_api/deserialization.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
require 'jsonapi'
2-
require 'jsonapi/deserializable'
1+
require 'jsonapi/parser'
2+
require 'jsonapi/rails'
33

44
module ActiveModelSerializers
55
module Adapter
@@ -83,7 +83,9 @@ def parse!(document, options = {})
8383
# on invalid payloads.
8484
def parse(document, options = {})
8585
# TODO: change to jsonapi-ralis to have default conversion to flat hashes
86-
JSONAPI::Deserializable::Resource.new(document).to_h
86+
result = JSONAPI::Rails::DeserializableResource.new(document, options: options).to_hash
87+
result = transform_keys(result) if options[:key_transform]
88+
result
8789
rescue JSONAPI::Parser::InvalidDocument => e
8890
return {} unless block_given?
8991
yield e

0 commit comments

Comments
 (0)