how to use json webservice in blackberry cascades -


1.how use json web service in blackberry cascades.

2.i need data url link qml page. give suggession sample if possible.

3.my web service link contains array type

for eg: { "address":["area": "chn", "city": "ght"]}

4.description: json link --> 192.168.1.251:410/mobile/service1.svc/english/category?countryid=1

5.by using above link please tell how retrive data json webservice in cascades.. need answer in cascades method..

right. 2 part question. first how make request , receive reply, , second how parse json; luckily, cascades has covered both cases.

to make 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 onfinished slot 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 " << addressmap["area"].tostring();             qdebug() << "city " << addressmap["city"].tostring();         }     }     else {         qdebug() << "server returned code " << reply->attribute(qnetworkrequest::httpstatuscodeattribute).toint()     } } 

for work, method has marked in class q_slot.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -