在Qt C ++ blackberry 10中解析JSON [英] Parsing JSON in Qt C++ blackberry 10
问题描述
这是来自任何URL http://www.example.com/json的我的JSON
"文本.php
This is My JSON
text from any URL http://www.example.com/json.php
请问谁能告诉我如何解析此json并将其放入Array中,以便可以在自定义ListView上进行模态化?
Please can any one tell me how do I parse this json and put it in an Array so that it can be modal on customized ListView?
让我告诉您,我是Blackberry开发的新手,以前是iOS开发人员.
Let me tell you that I am new to Blackberry development previously iOS developer.
我已经检查了此链接,但是无法运行它.
I have checked this link, but not able to run it .
如果任何人有完整的解决方案(示例或用法),请帮助我.
If any one have any complete solution(example or usage) please help me.
我从developer.blackberry.com下载了JSON
的示例,但无法运行.
I downloaded the sample of JSON
from developer.blackberry.com, but not able to run .
我还在此链接上发布了该问题>
I also posted that question at this link
{
"status": "success",
"result": [
{
"offer_id": "456",
"member_id": "648",
"offer_type": "printable",
"cat_name": "Health & Wellbeing",
"price": "50",
"discount": "20% Off.",
"title": "20% Off",
"quantity": "200",
"details": "Enjoy 20% Off any Service.",
"coupon_code": "45600010106",
"company_logo": "http://beta/files/offers/logos/",
"offer_image": "http://beta/files/offers/images/f4d118737e_image_456.jpg",
"bc_image": "http://beta/files/offers/qrcodes/qrcouponid_45600010106.png",
"company_address1": "Oud Metha - Mohammed Saeed Hareb Bldg. Opp. American Hospital",
"company_address2": "Not Available",
"company_city": "Not Available",
"company_phone": "04 357 6738 Mob: 509284567",
"location": "Oud Metha",
"company_name": "Golden House Gents Spa Club",
"merchant_name": "Golden House Gents Spa Club",
"url": "http://google.com",
"date_end": "2013/12/30",
"date_start": "2013/07/25",
"condition": "1. Cannot be Combined with any other offer.\r\n2. Advance booking required.\r\n3. This Voucher must be Mentioned during time of Booking.\r\n4. Not Valid on Thurs & Sat.\r\n5. Expires 31st December 2013.",
"rating": "0",
"latitude": "25.2374",
"longitude": "55.3117"
}
]
}
推荐答案
It's all explained in the documentation of JsonDataAccess
. You'll have to do something like this:
// Create a data model with sorting keys for title
GroupDataModel *model =
new GroupDataModel(QStringList() << "title");
// Load the JSON data
JsonDataAccess jda;
QVariant list = jda.load("yourfile.json")["result"].toVariantList();
// Add the data to the model
model->insertList(list.value<QVariantList>());
// Add your model to a ListView
listView->setDataModel(model);
这篇关于在Qt C ++ blackberry 10中解析JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!