My challenge is that in the database, JSON code was untidily stored.

```
{'isr_comment':'Test Comment',
'isr_depression_1': '1',
'isr_depression_2': '1'
'isr_depression_3': '1'
'isr_tested': 'true'
}

```

You see, all values are defined as string but some should be integers. It would be the best to have clean data already in the database but I cannot control how the data is entered. However my model looks like this.

```
class SessionPart < ApplicationRecord
...
  serialize :answers, JSON
...
end

```

As expected after deserialization is done I get strings as well.

```
@data=
  {"isr_Comment"=>"Test Comment",
   "isr_depression_1"=>"1",
   "isr_depression_2"=>"1",
   "isr_depression_3"=>"1",
   "isr_tested" => "true"}

```

But I need to do some calculation with this data so I need all possible values with a meaningful type.

```
@data=
  {"isr_Comment"=>"Test Comment",
   "isr_depression_1"=>1,
   "isr_depression_2"=>1,
   "isr_depression_3"=>1,
   "isr_tested" => true}

```

Is there any way to cast such data automatically?