Hi,
I'm giving APISmith::Smash a try to map a rich JSON input to Ruby objects.
I have a situation where I have a nested piece of data that I want to map, but not some of its parents.
data = {
article: {
titleOfTheArticle: "My Title",
authorList: {
author: {
name: "John Doe"
}
},
details: {
status: "published"
updatedAt: '2013-05-10'
}
}
}
class Author < APISmith::Smash
property :name
end
class Article < APISmith::Smash
property :title, :from => :titleOfTheArticle
property :author, :transformer => Author
property :updated_at
end
Here we can see that
- there is a nested
Author in Article and we do not need to keep the authorList intermediate
- the
updated_at value, nested inside details would be mapped directly into Article.
Are such things doable with APISmith, or I have to maintain all the hierarchy with classes?
Thanks
Hi,
I'm giving APISmith::Smash a try to map a rich JSON input to Ruby objects.
I have a situation where I have a nested piece of data that I want to map, but not some of its parents.
Here we can see that
AuthorinArticleand we do not need to keep theauthorListintermediateupdated_atvalue, nested insidedetailswould be mapped directly intoArticle.Are such things doable with APISmith, or I have to maintain all the hierarchy with classes?
Thanks