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
Posts: 26
Registered: ‎06-24-2013
My Device: Z10
My Carrier: Verizon
Accepted Solution

QVariantList with other QVariantLists inside of it?

Hello,

 

I'm parsing a JSON response from a QNetworkReply and turning it into a QVariantList as follows:

 

const QByteArray response(reply->readAll());
 
JsonDataAccess jda;
QVariant results = jda.loadFromBuffer(response).toMap();
m_theList = results.toMap().find("body")->toList();

 

 

Inside of the list, there are also OTHER lists that I need to access the elements of in QML. I am able to access the top level items such as name and description:

 

{
    "body": [
        {
            "id": "99d745e8-66b7-42e7-9de8-bd9edab7d085",
            "name": "Test Item",
            "description": "Test Description",
            "permissions": [
                {
                    "type": "Admin",
                    "status": "Pending"
                }
            ]
        }
    ]
}

 

However, when I try to access the "type" field of the permissions sub list, I don't get a result.

 

        listItemComponents: [
            ListItemComponent {
                type: "listItem"
                StandardListItem {
                    title: ListItemData["name"]
                    description: ListItemData.permissions["type"]
                }
            }
        ]

 Am I going about this wrong? Thanks!

Highlighted
Contributor
Posts: 26
Registered: ‎06-24-2013
My Device: Z10
My Carrier: Verizon

Re: QVariantList with other QVariantLists inside of it?

Figured it out. I wasn't giving it an index to look at inside of the other QVariantList. This fixed it:

 

description: ListItemData.permissions[0].type