Welcome!

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

Reply
Contributor
lvandyk
Posts: 19
Registered: ‎07-17-2012
My Device: BB 10 Alpha Device
My Carrier: Vodacom

Parse JSON with JsonDataAccess and display in ListView through a DataModel

Can anyone point me to further resources and examples on how to use JsonDataAccess to parse certain json data and display it in a ListView?

 

I have been trying all sorts of methods and none work.

 

If I simply wanted to show a list of items that are clickable and display more information, would a QListDataModel be the right choice?

 

Thank you!

 

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Parse JSON with JsonDataAccess and display in ListView through a DataModel

Have you looked at stampcollector and weatherguesser yet?  These should do what you want.

 

Stuart

Please use plain text.
Contributor
lvandyk
Posts: 19
Registered: ‎07-17-2012
My Device: BB 10 Alpha Device
My Carrier: Vodacom

Re: Parse JSON with JsonDataAccess and display in ListView through a DataModel

I've tried copying those examples but I still get issues.

 

I directly copied the code from: https://developer.blackberry.com/cascades/reference/bb__data__jsondataaccess.html#load 

 

but I get the following issue:

 

../src/MenuHandler.cpp:71:66: error: no matching function for call to 'bb::data::JsonDataAccess::load(QString)'

 

even though in the API it exists:

 

QVariant load (const QString &filePath)

 

Here is my code:

 

JsonDataAccess jda;
QVariant mainList = jda.load(QString::fromStdString("test.json"));

 

GroupDataModel *model = new GroupDataModel(QStringList() << "region");
model->insert(mainList);

myEventsLSTVW = new ListView();
myEventsLSTVW->setDataModel(model);

 

Any suggestions? Thanks!

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Parse JSON with JsonDataAccess and display in ListView through a DataModel

Have you switched to Beta2?

 

Stuart

Please use plain text.
Developer
mdodd
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE
My Carrier: Three

Re: Parse JSON with JsonDataAccess and display in ListView through a DataModel

+1 for this issue. Just imported an app created in Beta 1, made the changes recommended in the Upgrade To Beta 2 guide, and I get the error undefined reference to `bb::data::JsonDataAccess::JsonDataAccess(QObject*)'  when declaring the JsonDataAccess variable. 



Did this post help you? If so, please make sure to "like" it!
Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Parse JSON with JsonDataAccess and display in ListView through a DataModel

You need to add the corresponding library in your .pro file:

LIBS += -lbbdata

 

Stuart

Please use plain text.
Developer
mdodd
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE
My Carrier: Three

Re: Parse JSON with JsonDataAccess and display in ListView through a DataModel

Yep, that's worked for me. Thanks Stuart.


Did this post help you? If so, please make sure to "like" it!
Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer
My Carrier: developer

Re: Parse JSON with JsonDataAccess and display in ListView through a DataModel

As for the original question:

Were the samples enough to answer your question?

 

Stuart

Please use plain text.
Developer
nareshkodumuri
Posts: 125
Registered: ‎04-28-2012
My Device: BlackBerry 9800
My Carrier: BlackBerry

Re: Parse JSON with JsonDataAccess and display in ListView through a DataModel

[ Edited ]

Hi,

 

          You should add LIBS += -lbbdata to ur .pro file in ur project all the classes regarding JsonDataAccess are stored in bb::data namespace.so inorder to access these classes u need to add LIBS += -lbbdata  to ur .pro file in ur application.

 

Regards,

Naresh Kodumuri.

Please use plain text.
New Contributor
k_waheed_kotb
Posts: 8
Registered: ‎07-20-2013
My Device: BB Z10, BB Q10
My Carrier: Vodafone

Re: Parse JSON with JsonDataAccess and display in ListView through a DataModel

Yeah, that's worked for me. Thanks Stuart.
Please use plain text.