如何在黑莓级联中分割字符串

时间:2013-09-10 04:45:56

标签: blackberry blackberry-10 blackberry-simulator blackberry-cascades

  1. 我有一个像{"RegistrationResult":"Registered Success:Empid:157:TableName:COMPANY156"}

  2. 这样的json数组数据
  3. 现在我想如何分割字符串并在qml中显示列表视图,如下所示

    注册成功

    Empid = 157

    TableName = COMPANY156

  4. 请告诉概念拆分字符串在qml中显示结果

  5. 我可以获得以下方法的结果:{"RegistrationResult":["Registered Success","Empid":"157","TableName":"COMPANY156"]}

    但我不知道如何分割字符串..请帮助..

1 个答案:

答案 0 :(得分:3)

最后我通过参考文档获得了解决方案

http://developer.blackberry.com/native/reference/cascades/qstring.html#details

第1步: cpp 标题#include <QStringList>

中声明此内容

第2步:

JsonDataAccess jda;
        QVariantMap map = jda.loadFromBuffer(reply->readAll()).toMap();

        QVariantList addresses = map["RegistrationResult"].toList();

        qDebug() << "RegistrationResult is "<<map["RegistrationResult"].toString();


        QString result;
        QString empid;
        QString empid_no;
        QString companyname;
        QString::SectionFlag flag = QString::SectionSkipEmpty;

        result=m_temperature.section(':', 0, 0);
        empid=m_temperature.section(':', 1, 1);
        empid_no=m_temperature.section(':', 2, 2);
        companyname==m_temperature.section(':', 4, 4);