Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 48
Registered: ‎03-27-2011
My Device: BlackBerry Z10
My Carrier: Telstra

Populate GroupDataModel

I have successfully called an API via HTTP call. Returns a Json map, as example - 


{"results":[{"name":"Gambaro's MG Bar","id":"12908049","primaryContacts":[{"value":"(07) 3369 4533","type":"PHONE"}],"aboutId":"b7e9731db6dae4783da222aa8183153324a966a4d6bc9ba604d789f9275fb05f","hasExposureProducts":false,"listingType":"Business","reportingId":"eyJzb3VyY2UiOiJZRUxMT1ciLCJwcm9kdWN0SWQiOiIyNzg3Mjg2NTAiLCJwcm9kdWN0VmVyc2lvbiI6IjIifQ","primaryAddress":{"state":"QLD","type":"PHYSICAL","geoCodeGranularity":"PROPERTY","latitude":"-27.4644","longitude":"153.0126","suburb":"Petrie Terrace","postcode":"4000","addressLine":"33 Caxton St"},"categories":[{"name":"Bars","id":"10472","sensitive":false}],"detailsLink":"http://www.yellowpages.com.au/qld/petrie-terrace/gambaros-mg-bar-12908049-listing.html?referredBy=TA...","pureMobileBusiness":false},{"name":"St Pauls on Leichhardt","id":"14312179","primaryContacts":[{"value":"(07) 3831 8288","type":"PHONE"},{"value":"manager1@stpauls.com.au","type":"EMAIL"},............and so on.


I have also successfully parsed the Json map and created new GroupDataModel m_model. I have inserted the following code: 




I believe I have inserted the whole Json into the GroupDataModel?

For example, if I wanted to extract the following from the parsed Json data -


nameSmiley Frustratedt Pauls on Leichhardt

valueSmiley Sad07)3831 8288


What is the required code to populate my GroupDataModel?


If I need extra code, could somebody please help as I have come to a halt in my application.

Back in my QML, I have all the correct code to handle display of ListItemData.

Thank you.



Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: Populate GroupDataModel



"Results" in your JSOn is a List and not a Map. So, replace






m_model->insertList( jsonData.value("results").toList() );


Now, you will have a list of Maps, in your datamodel. You can simply use ListItemData.name and others..

Kanak Sony
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Posts: 48
Registered: ‎03-27-2011
My Device: BlackBerry Z10
My Carrier: Telstra

Re: Populate GroupDataModel

Thank you. Works good.

In my QML I have ListItemData.name -(returns the name ok)

If I use ListItemData.value - it returns message, Unable to assign [undefined] to Qstring.

What do I need to complete ListItemData. with so that I can return the phone number which resides in primaryContacts?