blackberryblackberry-10blackberry-simulatorblackberry-cascades

How to split string in blackberry cascades


  1. I have a json array data like {"RegistrationResult":"Registered Success:Empid:157:TableName:COMPANY156"}

  2. Now how i want split the string and show the list view in qml like the follwing

    Registered Success

    Empid = 157

    TableName = COMPANY156

  3. Please tell the concept to split a string and show the result in qml

I can get result for the follwing method: {"RegistrationResult":["Registered Success","Empid":"157","TableName":"COMPANY156"]}

But i dont know how to split the string.. Please help..


Solution

  • Finally i got solution by referring documentaion

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

    STEP 1: Declare this in cpp header #include <QStringList>

    STEP 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);