rails-api / active_model_serializers

ActiveModel::Serializer implementation and Rails hooks
MIT License
5.33k stars 1.39k forks source link

deserialization changed uppercase to lowervase in nested hashes #2425

Open artofhuman opened 3 years ago

artofhuman commented 3 years ago

Expected behavior vs actual behavior

input = {"include"=>"",
 "data"=>
  {"attributes"=>
    {"field_type"=>"dropdown",
     "name"=>"new field name",
     "description"=>"new field description",
     "enabled"=>false,
     "mandatory"=>true,
     "data"=>{"default_value"=>"new default value", "options"=>[{"OPTION 1"=>"OPTION 3"}, "new option 1", "new option 2"]}}},
 "controller"=>"api/v1/companies/custom_cv_fields",
 "action"=>"update",
 "company_id"=>"498",
 "id"=>"174"}

attention on nested hash "options"=>[{"OPTION 1"=>"OPTION 3"}

ActiveModelSerializers::Deserialization.jsonapi_parse(input)

=> {:field_type=>"dropdown",
 :name=>"new field name",
 :description=>"new field description",
 :enabled=>false,
 :mandatory=>true,
 :data=>{"default_value"=>"new default value", "options"=>[{"option 1"=>"OPTION 3"}, "new option 1", "new option 2"]}}

deserialization changes nested hashes. "options"=>[{"option 1"=>"OPTION 3"}

Expected behavior: deserialization should not change nested hashes

Environment

ActiveModelSerializers Version (commit ref if not on tag): gem 'active_model_serializers', '~> 0.10.8'

Output of ruby -e "puts RUBY_DESCRIPTION": ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

OS Type & Version: Linux

Integrated application and version (e.g., Rails, Grape, etc): Rails

bf4 commented 3 years ago

This something you think you might be able to investigate and propose a PR for? AMS is in maintenance now and I personally haven't used it in a while.