Rails アプリケーションで Web サービスの応答をオブジェクトに変換しようとしていますが、次の json を受け取りました。
{
"id": 1,
"status": true,
"password": "123",
"userType": {
"description": "description",
"userTypeId": 1
},
"email": "abc@gmail.com"
}
次のように UserType Ruby クラスの userType 属性を変換したい:
class UserType
attr_accessor :userTypeId, :description
end
私はActiveResourceを使用してWebサービスと通信しています。属性メソッドを使用してuserType json属性をUserTypeクラスに変換しようとしましたが、属性メソッドは複雑なタイプ、文字列、整数eなどのみを受け入れません...
userType (Web サービス応答) を UserType Ruby クラスに変換するにはどうすればよいですか?
Rails 3.2.12 および Ruby 1.9.3p194