We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, i have a JSON like this
{ "total_item": 250, "item_per_page": 50, "current_page": 1, "total_page": 5, "data": [ { "data": { "id": 1, "name": "Happy New Year 2016", "logo": { "ratio": 1, "path_1x": "https://3.bp.blogspot.com/-KUivQF0u7ME/VoMhw9LmM4I/AAAAAAAAASM/wt4gB6bT-Mk/s640/happy-new-year-2016-wishes.jpg", "path_2x": "https://3.bp.blogspot.com/-KUivQF0u7ME/VoMhw9LmM4I/AAAAAAAAASM/wt4gB6bT-Mk/s640/happy-new-year-2016-wishes.jpg" }, "main_category": { "id": 0, "name": "Mall" } }, "type": 2 },
Inside "data" got another "data". My model class is
var totalPage: NSNumber! var totalItem: NSNumber! var currentPage: NSNumber! var itemPerPage: NSNumber! var data: [T]!
What i going to do is i need to get the data.data from JSON and map to data. So i write a code
data.data
data
class func createFromJSON<T>(type: T, dictionary:Dictionary<String, AnyObject>, provider: InCodeMappingProvider) -> PaginateListModel<T> { var model = PaginateListModel<T>() model = ObjectMapper.sharedInstance().objectFromSource(dictionary, toInstanceOfClass: PaginateListModel<T>.self) as! PaginateListModel<T> let dictData = dictionary["data"] as! [Dictionary<String, AnyObject>] provider.mapFromDictionaryKey("data.data", toPropertyKey: "data", withObjectType: T.self , forClass: PaginateListModel<T>.self) ObjectMapper.sharedInstance().mappingProvider = provider model.data = ObjectMapper.sharedInstance().objectFromSource(dictData, toInstanceOfClass: T.self) as! [T] return model }
But i can't get the result. Please help. Thank you.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi, i have a JSON like this
Inside "data" got another "data". My model class is
What i going to do is i need to get the
data.data
from JSON and map todata
.So i write a code
But i can't get the result. Please help. Thank you.
The text was updated successfully, but these errors were encountered: