QVariant list = ja.loadFromBuffer(buffer);
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
AbstractPane *root = qml->createRootObject<AbstractPane>();
ListView *listView = root->findChild<ListView*>("liste");
GroupDataModel *model = new GroupDataModel(QStringList() << "nom" );
QVariantMap addresses = list.toMap();
foreach(QVariant var, addresses) {
QVariantMap addressMap = var.toMap();
qDebug() << "CategoryName is " <<addresses;
model->insert(addressMap);
}
listView->setDataModel(model);
When I run this the result that appear :
QMap(("test", QVariant(QVariantList, (QVariant(QVariantMap, QMap(("id", QVariant(QString, "1") ) ( "nom" , QVariant(QString, "samar") ) ( "prenom" , QVariant(QString, "20") ) ) ) , QVariant(QVariantMap, QMap(("id", QVariant(QString, "11") ) ( "nom" , QVariant(QString, "sarra") ) ( "prenom" , QVariant(QString, "1") ) ) ) , QVariant(QVariantMap, QMap(("id", QVariant(QString, "21") ) ( "nom" , QVariant(QString, "akgc") ) ( "prenom" , QVariant(QString, "3") ) ) ) , QVariant(QVar...
My question is how can i get the "nom" and "prenom" in my Json File
My JSON file URL: http://trackanddragutils.azurewebsites.net/json/json.php
Thanks for any help!! :i)
Try this: