Right. Well this is really a two part question. First is how to make a request and receive a reply, and second is how to parse the JSON; luckily, Cascades has you covered for both cases.
To make a request:
QNetworkAccessManager qNam;
QNetworkRequest req("192.168.1.251:410/Mobile/Service1.svc/english/Category?CountryID=1");
QNetworkReply *reply = qNam.get(req);
connect(reply, SIGNAL(finished()), this, SLOT(onFinished()));
Then define the onFinished slot as so:
void ClassName::onFinished() {
QNetworkReply *reply = dynamic_cast<QNetworkReply*>(sender());
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200) {
JsonDataAccess jda;
QVariantMap map = jda.loadFromBuffer(reply->readAll()).toMap();
QVariantList addresses = map["address"].toList();
foreach(QVariant var, addresses) {
QVariantMap addressMap = var.toMap();
qDebug() << "Area is " << addressMap["area"].toString();
qDebug() << "City is " << addressMap["city"].toString();
}
}
else {
qDebug() << "Server returned code " << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()
}
}
For this to work, this method has to be marked in the class as a Q_SLOT
.