is it QtCode effective?

You probably know that Qt and C++ are new for me after so many years of Java...

So here's a question:

This code is effective?

or something weong?

or could do better?

... Imagine a JSON as a result of the HTTP request like this:

{"body": {"token":"1234","sample":"one"},"error":""}

and this C++ code:

// reply is QNetworkReplyQByteArray s = reply->readAll();JsonDataAccess jda;
// we load a JSON with root as Object
QVariant rootObject(jda.loadFromBuffer(s));
if (!rootObject.isNull()) {
    // there are some values at root, so we get a Map
    QVariantMap rootMap(rootObject.toMap());
    if (!rootMap.isEmpty()) {
        // now see if there's a body
        QVariant level1(rootMap.value("body"));
        if (!level1.isNull()) {
            // level1 contains some Values in a map
            QVariantMap level1map(level1.toMap());
            if (!level1map.isEmpty()) {
                // now let's process the entries
                QString tokenString(level1map.value("token").toString());
                if (!tokenString.isEmpty()) {
                    // YEP we found the token
                    qDebug() << "TOKEN:" << tokenString;
                } else {
                    qDebug() << "tokenstring is empty";
                }
                // no process other entries
                // .......
            } else {
                qDebug() << "level1 body found, but is empty";
            }

        } else {
            qDebug() << "level1 body is null !";
        }
        // parse for an error entry
        level1 = rootMap.value("error");
        if (!level1.isNull()) {
            // level1 contains some Values in a map
            QString errorString(level1.toString());
            if (!errorString.isEmpty()) {
                qDebug() << "ERROR:" << errorString;
            } else {
                qDebug() << "errorString is empty";
            }
        } else {
            qDebug() << "level1 error is null !";
        }
    } else {
        qDebug() << "root is no QMap or empty";
    }
} else {
    qDebug() << "root is no QVariant";
}

the JSON is simplified - actually, some levels with strings and integers (ints)

THX

const QVariantMap data = jda.loadFromBuffer(s).toMap()
if(map.contains("body") {
const QVariantMap body = data.value("body").toMap();
QString token = body.value("token","").toString();QString level = body.value("level","").toString();
if(token.isEmpty()) { } //no token found
}if(map.contains("error")) {//do what you want with the error}

You could do this in wayyyyyyy less lines.

Tags: BlackBerry Developers

Similar Questions

  • How to eliminate a brilliant on the face effect

    I would be grateful a tips on how to eliminate this effect, shining on the face of this actor

    Makeup artist 3 filter Softworks Sheffield ($100), available for FxFactory.

    Perfect skin was completely written from scratch. With the new algorithms of smoothing (including one for addressing the black spots and dark spots), refined selection techniques of the skin (with a new control interface on the screen with the possibility of areas of the mask of the screen) and a feature of the skin with the size, lighting, texture and depth controls, perfect skin is the cornerstone of any beauty Kit.

    http://www.sheffieldsoftworks.com/

  • Bubble effect does not

    Just download the latest version of the software, and the new effect of bubble in the messages seems not to work.  Tactile 3D works well, but does not appear in messages

    Check the settings > general > accessibility and make sure you have Motion cut off.

  • I have iOS 10 and I am still unable to make messages with animation effects. How can I solve this problem?

    I have iOS 10 and I am still unable to make messages with animation effects. How can I solve this problem?

    Without knowing what is happening when you try, it is difficult to recommend troubleshooting. However, one of the first steps is to ensure that you don't have to reduce the Motion activated in accessibility.

  • How to disable the sound effects?

    After the upgrade to Sierra, various applications now have sound effects. I unchecked sound effects as part of its interface. But the mail still makes a swoosh sound when sending anything. I don't know yet what other applications continue to use sound effects.

    Is it possible to disable all sound effects?

    Some applications have their own internal settings not affected by system settings in the Finder

    for example, to disable the "Swoosh" in mail go to mail > Preferences, click the general tab and clear the sounds of other messaging features.

  • iOS 10 effects e-mail: they are available on the iPhone 6 s?

    When I press the blue arrow 3D (after the text entry) I get nothing. This feature is enabled on the iPhone 6 s?

    Go to settings > general > accessibility > reduce Motion > Off. If it is enabled, the effects will not work.

  • Effects of e-mail in IOS 10

    I downloaded the new OS and now I can't send a message without adding a kind of effects as balloons and confetti.

    How to disable this option?  It's really annoying!

    Just a short click the blue up arrow.

  • effects of IMessage can be received but not sent

    On my old iPhone 6 and I had a problem where I could send effects iMessage, but not receive them. I solved this by disabling the reduced movement and signing in iMessage (some so I had been using my phone for centuries while disconnected (e) which!).

    Today my iPhone more 7 arrived and I now have the opposite problem - I get the effects but I can't send them. When I click and stand on the blue arrow, after a few seconds, the screen goes blurred except for the text that I just wrote. I have no menu showing me various effect options.

    Any ideas what is the cause? I have tried toggling movement reduced on and outside, iMessage on and outside, iMessage signature and put it back, but none of this has made a difference.

    Hi porrig!

    It's always exciting to have a new iPhone. I'm glad to hear you have the iPhone 7 more! iMessages with effects of message sending is a fantastic new feature of iOS 10. You are in the right place for help.

    Your new iPhone Plus 7 has the ability to detect different levels of pressure used. This feature is called Touch 3D. You may notice additional options by pressing firmly on the applications, for example, because of this feature.

    In this case, it seems that you use the right process to send the effect of the message, but the blue arrow may need a firmer touch that you are currently using. Try to use a firmer touch on the blue arrow to see if the message options.

    If this solves the problem for you, but you want to adjust the firmness necessary to display these options, check out this resource:

    Change 3D on your iPhone 6s or 6s iPhone tactile sensitivity more

    The resource applies to your iPhone 7 more, too!

    Take care!

  • Effects of the bubble

    How do you send balloons with the effect of bubble in iMessage?

    You ask about doing it on the MacBook Air? If not, and referring to the iPhone, check this page in the iPhone user Guide. http://help.Apple.com/iPhone/10/#/iph3d4cb79c9

    If you're talking about the MacBook, I don't know if this is a feature for iMessage on the computer. But then, I'm not a Mac user and could not be sure of that.

  • Effects of message does not

    I'm not running an iPhone 6s more und have upgraded to the latest version of iOS 10 (and even reinstalled two times).

    When 3D-pressing the button send in messages, no effect appear. However, all the other new goodies in the messages work.

    Any advice much appreciated

    Daniel

    Hi Daniel

    You send or receive the bubble or full screen effects if reduce Motion is running.

    • Go to: settings > general > accessibility > Motion reduce > disable.

    Effects of the message can apply to messages sent through iMessage (own Apple service), which appear in blue in the Messages. They cannot be applied to SMS or MMS messages (shown in green).

    More information:

    Use effects of message with iMessage on your iPhone, iPad and iPod touch - Apple Support

  • I spent hours on web sites looking for advice clean my iMac - they were all dead ends.  I send a question to this 'Community' first, but must have done it badly because there was no trace of it.  I have the effect on this model beach ball

    I spent hours on web sites looking for advice clean my iMac - they were all dead ends.  I send a question to this 'Community' first, but must have done it badly because there was no trace of it.  I now have the beach on this computer ball effect.  Are there places I can delete cookies etc to help out?  Thank you for your help.

    horse8905

    Don't know what's happening, you do not give a lot of information, but if you have the constant beachballing (spinning wait cursor), which could mean that the hard drive is dying.

    Open Console.app in Applications > utilities. Filter, called "String Matching," right, high enter "I/o" without the quotes. What happens when you do this?

  • I'm unable to use special effects in the Messages on my iPhone 7.    Does anyone else have this problem?

    I did reduce the Motion is turned off.  If I try press the blue arrow, nothing happens.

    Hello, Lfsawyer!

    Thank you for reaching out by Apple Support communities. I understand from your post, that effects full screen do not work for you in iMessage after update to iOS 10, even if you have verified that reduce the Motion died. I have really enjoyed all the new iMessage effects and whether you are able to enjoy it, too - I'd be happy to help you!

    I have a little I can recommend troubleshooting measures. Before you begin, create a backup of your iPhone using iCloud or iTunes. You can get the instructions to do it here: How to back up your iPad, iPhone or iPod touch

    So, try the following in order, testing after each step. Stop when the problem is resolved.

    1. Restart your iPhone by following the instructions here: restart your iPad, iPhone or iPod touch
    2. Reset your iPhone settings in settings > general > reset > reset all settings. None of your personal data (contacts, photos, calendar events, reminders, etc.) will be deleted, but customizable settings (brightness screen and paper painted, alert sounds, the Date and time settings, etc.) will be returned to their default values. Also, saved networks Wi - Fi and passwords will be deleted, as well as the AFN or previously used VPN settings.
    3. Restore your iPhone settings, use the steps in this article: use iTunes on your Mac or PC to restore the iPhone, iPad, or iPod touch to factory settings

      Once the restore is complete, configure your iPhone as a new device (i.e. without your backup, at least temporarily). You can sign in iMessage FaceTime, iCloud and iTunes and the App Store with your Apple ID then test your ability to send effects.

      If you can send these effects full screen after the restore, go ahead and put your backup on the iPhone using this article: restore your iPhone, iPad or iPod touch from a backup

    Happy messaging!

  • Why can't receive the new message effects

    I upgraded my iPhone 6 more the new iOS 10 and I can send the new message effects to other iPhones with the update, but when they send messages to me I don't see how another bubble text that follows the message saying "(envoyé avec effet de Chelem)". " The reduced movement is disabled.

    Hey there trama91! Thank you for using communities of support from Apple!

    I love all the new features of iOS 10 so then I'll be more than happy to help with your iPhone on iOS 10 6 Plus receives these new effect.

    How to back up your iPhone, iPad and iPod touch --before troubleshooting a device, I always recommend a fresh backup. Is better "" than "need."

    1. forcing a nearby app on your iPhone, iPad or iPod touch - first, quit all running applications, and then restart your iPhone, iPad or iPod touch - never underestimate the power of a good restart.

    2. reset the iPhone settings - on your phone, go to settings > general > reset > reset all settings. This step will return your iPhone settings by default. Don't forget to write your networks, Wi-Fi/passwords before finishing.

    Guide to the iPhone user - there are many other new features of iOS 10 and I wanted to be sure that you were aware of all.

    Hope this helps and have a great day!

  • Effects bus

    My guitar tutor asked me not to include the effects upon registration of securities, but to add as own and then add effects on a bus.  I wasn't quite sure what he meant, so when I got home I couldn't find anywhere to do this.

    Can someone advise?

    On the subject of GarageBand, has nothing to fear, because she always saves the original 'clean' signal as it is without adding effects. All the effects that you add with plugin in GarageBand, even if you hear while recording, are added to the 'read' signal', 'monitor' with effects without actually their registration. This is why you can change the sound in any way at any time after registration.

    However, if you save a processed signal (physical real pedals add to your guitar sound and record this signal, then of course, this signal will be recorded like that and you can't 'make clean again').

    Bus

    CE that your professor is referring is an audio production technique, where you (route) also send part of the signal on a track to another track (called a track to the) via a so-called 'Bus', add an effect on this track to the (reverb, delay, etc.) and mix two signals of tracks depending on how the original signal and how much the signal effect you want.

    GarageBand has no bus (at least not outdoors). Any effect you want to add is done by adding Plugins directly on the track, not need to bus. (An exception is Master effects).

    Hope that helps

    Edgar Rothermich - LogicProGEM.com

    (Author of "Graphically improved manuals")

    http://DingDingMusic.com/manuals/

    "I could receive some form of compensation, financial or otherwise, my recommendation or link."

  • effects of iMessage iPhone 7

    Got 7 iPhone today but dir a reason that I can't send the effects such as balloons and confetti in iMessage.

    Reduced movement is disabled.

    Any ideas?

    The beneficiary must:

    • Having the iOS 10
    • Use iMessage

    If you are unable to send effects, make sure what you do so correctly.  iPhone Touch 3D 7A, then you will need to press the arrow to see the options.

    http://help.Apple.com/iPhone/10/#/iph3fadba219

Maybe you are looking for