|
|
|
|
|
by beerkg
1484 days ago
|
|
Ah, I messed up the example, Person class definition should look like this: class Person < Shale::Mapper
attribute :first_name, Shale::Type::String
attribute :last_name, Shale::Type::String
attribute :age, Shale::Type::Integer
attribute :married, Shale::Type::Boolean, default: false
attribute :hobbies, Shale::Type::String, collection: true
attribute :address, Address
end
And the JSON used for parsing also should contain those atttributes, like: {
"first_name": "John",
"last_name": "Doe",
"age": 30,
"married": false,
"hobbies": ["Singing", "Dancing"],
"address": {
"street": "Oxford Street",
"city": "London"
}
}
|
|