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
Developer
Posts: 164
Registered: ‎07-23-2013
My Device: Blackberry z10
My Carrier: Airtel

json array in list view

1.Array Type

{"DATA":
[
{"CategoryID":"3","CategoryName":"News","CountryID":"1","Result":"OK"},
{"CategoryID":"4","CategoryName":"Daily Paper","CountryID":"1","Result":"OK"},
{"CategoryID":"5","CategoryName":"Thanthi","CountryID":"1","Result":"OK"},
{"CategoryID":"1","CategoryName":"Newspaper","CountryID":"1","Result":"OK"},
{"CategoryID":"2","CategoryName":"Magazine","CountryID":"1","Result":"OK"}
]
}

 

 

 

2.Direct Type
[

{"CategoryID":"3","CategoryName":"News","CountryID":"1","Result":"OK"},
{"CategoryID":"4","CategoryName":"Daily Paper","CountryID":"1","Result":"OK"},
{"CategoryID":"5","CategoryName":"Thanthi","CountryID":"1","Result":"OK"},
{"CategoryID":"1","CategoryName":"Newspaper","CountryID":"1","Result":"OK"},
{"CategoryID":"2","CategoryName":"Magazine","CountryID":"1","Result":"OK"}

]

for direct type declaration ---> 

 

ListItemComponent {
type: "listItem"
StandardListItem {
title: ListItemData.CategoryName
}
}

 

my question is how to declare title: ListItemData.???????  for first json model

___________________________________________________________________________________________

*************Plese *********LIKE**** & ****ACCEPT as Solution*** If you got suggestion for your Query.

@RAJESH SVM ----- Blackberry Mobile App Developer, Blaze, India.
Trusted Contributor
Posts: 139
Registered: ‎08-22-2013
My Device: None
My Carrier: Aircel

Re: json array in list view

which development tool is used like native sdk or webworks sdk?

Developer
Posts: 164
Registered: ‎07-23-2013
My Device: Blackberry z10
My Carrier: Airtel

Re: json array in list view

am using native sdk  CASCADE DEVELOPMENT

 

Page {
content: Container {
Label {
text: "List View with json parsing"
}

ListView {
id: listViewDemo
dataModel: GroupDataModel {
grouping: ItemGrouping.None
}

listItemComponents: [
ListItemComponent {
type: "listItem"
StandardListItem {
title: ListItemData.????????????    (for my first query)
}
}
]

function itemType(data, indexPath) {
return "listItem";
}
}
}

 

___________________________________________________________________________________________

*************Plese *********LIKE**** & ****ACCEPT as Solution*** If you got suggestion for your Query.

@RAJESH SVM ----- Blackberry Mobile App Developer, Blaze, India.
Trusted Contributor
Posts: 139
Registered: ‎08-22-2013
My Device: None
My Carrier: Aircel

Re: json array in list view

Developer
Posts: 164
Registered: ‎07-23-2013
My Device: Blackberry z10
My Carrier: Airtel

Re: json array in list view

am tried that already..

 

it shows result for --> 

[

{"name": "abc", "address": "xyz"},

{"name": "acd", "address": "x9z"}

]

 

but i need result for

{"MyDetails":

[

{"name": "abc", "address": "xyz"},

{"name": "acd", "address": "x9z"}

]

}

 

___________________________________________________________________________________________

*************Plese *********LIKE**** & ****ACCEPT as Solution*** If you got suggestion for your Query.

@RAJESH SVM ----- Blackberry Mobile App Developer, Blaze, India.
Developer
Posts: 164
Registered: ‎07-23-2013
My Device: Blackberry z10
My Carrier: Airtel

Re: json array in list view

am new to bb cascade development... please anybody help..

___________________________________________________________________________________________

*************Plese *********LIKE**** & ****ACCEPT as Solution*** If you got suggestion for your Query.

@RAJESH SVM ----- Blackberry Mobile App Developer, Blaze, India.
Trusted Contributor
Posts: 139
Registered: ‎08-22-2013
My Device: None
My Carrier: Aircel

Re: json array in list view


Try my below code buddy:

 

C++:

GroupDataModel *model =
new GroupDataModel(QStringList() << "name" << "address");

// Load the JSON data
JsonDataAccess jda = jda.load("contacts.json");;
QVariant list = jda.value("MyDetails").toList();

// Add the data to the model
model->insertList(list.value<QVariantList>());

//Create a ListView control and add the model to the list
ListView *listView = new ListView();
listView->setDataModel(model);

 

it's may be working or if u got an any problem reply me ok don't worry Smiley Happy

Trusted Contributor
Posts: 139
Registered: ‎08-22-2013
My Device: None
My Carrier: Aircel

Re: json array in list view

have you tried my solution buddy?

Developer
Posts: 164
Registered: ‎07-23-2013
My Device: Blackberry z10
My Carrier: Airtel

Re: json array in list view

will you please send the full source code of c++ file..

___________________________________________________________________________________________

*************Plese *********LIKE**** & ****ACCEPT as Solution*** If you got suggestion for your Query.

@RAJESH SVM ----- Blackberry Mobile App Developer, Blaze, India.
Trusted Contributor
Posts: 139
Registered: ‎08-22-2013
My Device: None
My Carrier: Aircel

Re: json array in list view

this time i don't have c++ file buddy this code from my reference! can tried last post link for json data access just modify with this code.