2 ms·
In the last example, where does it find the values for the `married`, `age`, `zip` and `hobbies` attributes? They are not present in the JSON string?
by WJW 4y ago
In the last example, where does it find the values for the `married`, `age`, `zip` and `hobbies` attributes? They are not present in the JSON string?
- beerkg 4y agoAh, 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" } }