Quick help with json file

Hi all

I'm trying to find a way to dig a json file. This is the structure of the file

{
   "company" : 1,
   "employees" : [
      {
         "firstname" : "Tim Tom,
         "more_info" : {
            "address" : "123 lausanne",

         }
      }
   ],
   "total" : 750
}

right now I have used covered to do this way.

bb::data::JsonDataAccess ja;
QVariant jsonva = ja.loadFromBuffer(response);

QVariantList employeeList = jsonva.toMap().find("employee")->toList();

QVariantMap infoList = jsonva.toMap().find("employee")->toMap().find("more_info")->toMap();

So the first employee works. I get the data off of it, including more_info

but for the second, which doesn't seem to work. Is it because I need to loop on my first list?

Thank you for the help

Hello

Browse the list using foreach:

QVariantList employeeList = jsonva.toMap()["employees"].toList();

foreach (QVariant v, employeeList)
{
  QVariantMap employeeData = v.toMap();
  QVariantMap moreInfo = employeeData["moreInfo"];
}

An important point to note is that function find() can potentially return mapName.end () if the name was not found in the map. If you do not check for this case explicitly, the application will crash the incorrect entry.

Another option which I use above is using operator [] that creates the key value if it is missing, and always returns a reference valid value, so it is not necessary validate the result.

Tags: BlackBerry Developers

Similar Questions

  • Help with JSON HTTP Post request

    Still fairly new to QT so I try to send a query with some json http post, I'm pulling the json to a file and which seems to work fine but I get a http 500 error. I want to just make sure that my code is correct before contacting the company that webservice I use here is my code:

     JsonDataAccess jda;
        QVariant list = jda.load(QDir::currentPath() +"/app/native/assets/jsonData/myjson.json");
    
        qDebug()<post(request, list.toByteArray());
    

    I have a feeling that I'm passing in json data in the wrong post method. Any help is appreicated

    Hello

    You send an empty server string because list.toByteArray () returns an empty string.

    You must save the QByteArray list;

    QByteArray result;
    jda.saveToBuffer(list, &result);
    
    // and then
    
    QNetworkReply *reply = networkAccessManager->post(request, result);
    

    or

    Simply load the json with QFile file

    QFile file(YOUR_JSON);
    if (!file.open(QIODevice::ReadOnly)){
        qDebug() << Q_FUNC_INFO << file.errorString();
        return;
    }
    QByteArray result = file.readAll();
    file.close()
    
    QNetworkReply *reply = networkAccessManager->post(request, result);
    

    Hoe it helps

  • Need help with raw files

    I reinstalled and updated CS5, but I'm unable to open camera raw to my Canon Rebel T4i. I get the following message:

    Could not complete your request because the file appears to be a model of camera that is not supported by the installed version of Camera Raw.

    Please visit the Camera Raw help documentation for more information.

    Camera Raw is a plug-in in Adobe Photoshop, Photoshop Elements and Lightroom dealing with Raw files. Camera Raw should be updated for each new brand and model of camera that comes on the market. Camera Raw is frequently updated, but not all versions of Camera Raw are compatible with all versions of Photoshop.

    See 't-my-version-of-photoshop-or-lightroom-prise in load-my - http://blogs.adobe.com/crawlspace/2011/03/why-doesn camera .html

    According to http://helpx.adobe.com/creative-suite/kb/camera-raw-plug-supported-cameras.html

    the rebel T4i was first supported by Camera Raw 7.1.

    Camera Raw 7 + is only compatible with CS6 and higher.

    http://helpx.Adobe.com/x-productkb/global/camera-raw-compatible-applications.html

    Your choice:

    1. CS6 update
    2. Join the Cloud
    3. Convert all your T4i Raw DNG files using free Adobe's DNG Converter
      http://www.Adobe.com/products/Photoshop/extend.displayTab2.html
      Then, edit the DNG in your existing CS5.
  • Help with Raw files

    I use an Imac with processor PowerPC G5 2.1 Ghz running OS X 10.5.8 and Photoshop CS2.  I just bought a Nikon D300s and want to work with raw files.  Adobe told me that I need to CS5, which means that I would need to buy a new computer.  Is this in any way about this?

    You will need to convert your raw files to DNG with Adobe free Converter: http://www.adobe.com/products/dng/

  • Need help with eps files

    Hi all I bought this stat reflections eps file, I want to use the icon in the lower right, but do not know how to separate the background... I need like a png... Oh can smart designers, anyone help? 10967425_s.jpg I tried to download the eps, but was not allowed to download it... Please please advise!  A big thank you.

    Here's a quick I did with the starfilter. It's a 1000 pixel wide PNG, so if it's enough, you can try this.

    Put it in "Screen" blend mode on your image, and it will look something like this:

  • Satellite U940 - 11b - need help with recovery files

    Madam/Sir,

    I have a question about a failure U940 - 11 c.

    The laptop crashed after be closed during recovery of windows procedures. I think that Windows is damaged, as a result, the laptop no longer starts. When turing the laptop on the following message is displayed: reboot and select proper boot device. See the image below:

    Files on the hard drive are very precious to me, so the hard drive can not be reset until I got the files. I tried to recover the boot files Ubuntu from a USB flash drive. Ubuntu began without any difficulty. The problem is that Ubuntu is not able to find the Windows hard disk. From Gparted, the following errors occurred:

    1. WARNING: / dev/sda contains the signatures of TPG, indicating that she has a GPT table. However, it doesn't have a valid fake msdos partition table, as it should. Maybe it has been altered - possibly by a program that does not include the GPT partition tables. Or maybe you deleted the table GPT and are now using a msdos partition table. It is a GPT partition table? :

    2. the GPT backup table is not at the end of the disc, as it should. This may mean another operating system to think that the drive is smaller. FIS, by moving the backup at the end (and revmoving the old backup)? :

    3. not all the space available to/dev/sdb appears to be used, van correct you the GPT to use all the space (special edition 39007920 blocks) or continue with the current configuration? :

    4. the disk is allocated:

    Do you have tips or advice that could help me get the files from the hard drive. I do not understand the errors and will not be able to solve this problem. Thanks in advance.

    Hello

    I suggest that you use the tool to disks in Ubuntu to mount your Windows partition.
    If the partition is damaged in an aborted recovery (or other reason), you will need to invest a lot of time and effort to successfully recover your data.

    Tom BR

  • Need QUICK help with XP Recovery Console

    My computer has rejected the slightest error and says to insert disk at startup to enter R for repair through the repair console and windows (he said I was missing a windows / file fat32.) I followed these instructions and it took me to the recovery console which someone else told me to enter chkdsk/r at the command prompt I did and he told me that the volume appears to contain one or more unrecoverable problems. All solutions on how to solve this problem or what might be the problem or maybe I'm not in the right order? Please help me soon I have files on this computer, that I need.

    Start the computer with a Linux Livecd such as Knoppix or a Bart PE and copy the data files on an external hard drive or USB key. Then test the hard drive as it looks to be a failure.

    http://www.Knoppix.NET
    http://www.nu2.nu/pebuilder/ - Bart PE Builder

    http://www.elephantboycomputers.com/page2.html#Hardware_Tshoot

    If you can't do the work yourself (and there is no shame in admitting this isn't your cup of tea), take the machine to a professional computer repair shop (not your local equivalent of BigComputerStore/GeekSquad). MS - MVP - Elephant Boy computers - don't panic!

  • I'm trying to get help with corrupted files or missing. I can't use my recovery Cd, because the file is missing in order to make it work properly.

    I tried to use the restore cd that came with my pc it want to work because it lacks the file I need to perform a recovery and try to fix it. Some of my updates are not installed.

    Hello

    1. have you received an error when update failed?
    2. that you get an error message saying that some files are missing or corrupt?

    You can check for errors in the Windows Update history.
    To check the update history:
    a. Click Start, click Control Panel.
    b. now click on Windows updates.
    c. click view update history.

    Refer to this link for help:
    http://Windows.Microsoft.com/en-us/Windows7/see-which-Windows-updates-are-installed

    Try to analysis of SFC (System File Checker) running on your computer.

    Scan SFC will Windows replace corrupted or missing system files on your computer.
    Scan sfc enforcement procedure:
    a. Click Start, click principally made programs, accessories, right-click on command prompt and select run as administrator.
    b. click on continue or provide administrator credentials if prompted.
    c. in the type in the following command prompt window and press ENTER:
    sfc/scannow

    Refer to this article for more information:
    http://support.Microsoft.com/kb/929833

    Let me know the exact error messages and also a brief description of your problem so that we can advance troubleshooting.

    Kind regards
    Afzal Taher-Microsoft Support.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Help with image files, drop box and save the changes?

    My husband put all our photos of drop box.  They are still on our computer, but we can now also access elsewhere.  But it has somewhat modified files.

    I'm putting together, cultures and (in general) to save the changes made to some images.  But I get an error.

    Example: The image I want to change is on the side.  I right-click on the file icon and select "Rotate clockwise" in the menu dropdown. Immediately, I raise the sound "bonk" and an error message appears: "you cannot rotate this image.  The file can be used or open in another program or maybe the file is read only.  It wasn't a problem before doing things to the drop box.
    So, I wait to make sure that everything is ok.  The image is not open anywhere else.  I clicked the properties option to see if it is in read-only mode.  He said that it is not.
    When I open the image and try to use the rotation on the bottom, it will turn.  But when I close the window, I get a different error message that says "Windows Photo Viewer cannot save changes to this picture because there is a problem with the properties of the image file."   There is a link at the bottom of the message box for "Why can't save this picture?  I clicked it.  He said "the subject you are looking for is not available in this version of Windows. For additional assistance, see multiple support options. "The more support options?  Get a tech savvy friend who could help me. Nice.
    Anyone know what I need to do to make this work?
    I don't know what version of windows we have.  I'm sure that's not Vista.  It's the one after that.

    Hello

    Thank you asking in the Microsoft Community.

    1. open Microsoft paint.

    2. navigate to the image through Microsoft Paint.

    3 try to rotate and save the image.

    4 let me know if you are able to.

    Post back with the result.

  • Help with html files when you place the overlay Web content

    Hello

    We have an educational application with plenty of interactive exercises - which were originally designed in Flash.

    I have converted in HTML using Wallaby fla files. For each fla file, Wallaby creates a js, css and html file but also an active file.

    When I place the frame Web Content, and then link it to the html file, it link to the real HTML created Wallaby? It wont let me select the folder containing all the files in that, and I can't link to a zip file either... Then, how it recognizes assets if I select only the html file? (see screenshot)

    Screen Shot 2013-03-28 at 2.09.20 PM.png

    Or do I need to add a HTMLResources file and bind it to who?

    Thanks in advance for any help.

    You a link to the HTML file but make sure that these things are in their own folder or InDesign will add EVERYTHING in the folder that has the HTML in there.

    Bob

  • Need help with exe files.

    I am looking for an exe file to play on the laundry. How to insert the exe file in dreamweaver 8 to play when the page is loaded. Very similar to a flash movie is loading. The file is created with the extension exe and I can't change it or recreate. any help is appreciated. Thank you

    In general you can not do this on anything other than an intranet. Is it
    where you work? If so, then you should investigate using
    ActiveX to run this exe file - check the Microsoft site...

    --
    Murray - ICQ 71997575
    Adobe Community Expert
    (If you * MUST * write me, don't don't LAUGH when you do!)
    ==================
    http://www.dreamweavermx-templates.com - template Triage!
    http://www.projectseven.com/go - DW FAQs, tutorials & resources
    http://www.dwfaq.com - DW FAQs, tutorials & resources
    http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
    ==================

    "brananc1" wrote in message
    News:ee265m$LCT$1@forums. Macromedia.com...
    > I'm trying to get an exe file to play on the laundry. How do I insert the
    > exe
    > file in dreamweaver 8 to play when the page is loaded. Very similar to the loading
    > a
    > flash animation. The file is created with the extension exe and I can't
    > change
    > who or recreate. any help is appreciated. Thank you
    >

  • Need help with flashing file + question mark at startup

    My Macbook Pro has worked fine until yesterday. On startup, I get the flashing file, so I rebooted and held command + R. Once I have try disc recovery/upgrade to update OS/restoration I need a startup disk file to choose and everything is empty. How can I get the possibility of a boot disk? Do I need a physical disk? I just checked my box of the laptop and I don't have a physical disc.

    Thank you.

    If a flashing question mark appears when you start your Mac - Apple Support

    Which shows in disk utility that is located in the recovery?

    Cutting in-house of may have failed or yo have a problem with the internal connection.

    What model of MacBook Pro?

    This is the Office Mac Pro forum. I asked that your post moved to the forum of laptop MacBook Pro or another appropriate forum.

  • No HELP with OE6 file dbx missing no bak file

    Hi hope someone can help! my computer is old w/decrease storage and OE inbox has suddenly lost most of the emails. I know the old routine in what concerns the use of the .bak folder in the trash, but I did not!  I see the huge dbx file, but I can't restore it. I tried to compact the Inbox last night, but he said that there was not enough space. can anyone help? I'm afraid extract dbx will cause a crash. Thank you

    So can OK, you give me some steps to try to build on a new computer?

    A new computer into a XP machine? Right-click on the old Inbox.dbx file and drag it to a flash drive, choose copy here. Drag it from the flash player on the desktop of the other machine and then right-click | Properties and make sure it is not set to read only. Run DBXpress on the record.

    Or did you mean something else?

    Change. If you get a Win7 Pro, business, or ultimate edition, you can use OE in XP Mode.

    How to use Outlook Express in Windows 7
    http://www.oehelp.com/OEnWin7.aspx

  • Help with C++ file path

    Must do something stupid here:

    QFile file("asset:///images/test.gif");
    
    if(file.exists()) {qDebug("file exists");} else {qDebug("no file there");}
    

    I always get 'no file' and tried:

    • Asset:///images/test.gif
    • Asset/images/test.gif
    • /Asset/images/test.gif
    • /Accounts/1000/APPDATA/com.example.ClipboardTest.testDev_ipboardTestd1618f7_/asset/images/test.gif
    • file:///accounts/1000/APPDATA/com.example.ClipboardTest.testDev_ipboardTestd1618f7_/asset/images/test.gif

    where the channel long 'accounts' is the result of:

    QDir dir;
    QString myString = dir.absolutePath();
    const char* myChar = myString.toStdString().c_str();
    qDebug(myChar);
    

    How the hell can I get a file in my current directory loaded into a QFile object? Once it works, I'll test the following section:

    //Open the file
        if(file.open(QIODevice::ReadOnly)) {
            qDebug("file.open SUCCESS");
        } else {
            qDebug("file.open FAILED");
        }
        QByteArray data = file.readAll();
    

    Thank you!

    I think that the assets: / / / does not work with QFile.
    Try "app/native/assets/images/test.gif".

    or QDir::currentPath() + "/ app/native/assets/images/test.gif".

  • Need help with some files

    Then I opened the Task Manager today only to find 3 things I'd never seen before, they were atieclxx.exe, csrss.exe and winlong.exe. I did a bit of googoling (?) and I'm a bit confused. I see a few similar questions on other forums were people said that they were a form of spyware, while others apparently say it is just a process about my graphics card and normal to run, but I had never seen before.

    I would be grateful if someone could give me some clarification.

    Thank you.

    For peace of mind I suggest you run a malware check

    I recommend that you run Disk Cleanup or cCleaner to remove temporary files as this will reduce the time to scan security software.

    Start the computer in safe mode with network and download and install Malwarebytes (free version for individuals only), updated definitions and run in normal mode. Disable other security software while you do the analyses.
    http://www.computerhope.com/issues/chsafe.htm

    http://www.Malwarebytes.org/products/malwarebytes_free
    http://helpdesk.Malwarebytes.org/entries/21892442-should-I-scan-with-Malwarebytes-anti-malware-in-safe-mode-

    Download and run SuperAntiSpyware (Free Edition)
    http://www.SUPERAntiSpyware.com/download.html

Maybe you are looking for

  • Just unloading scheda su wireles pc

    Ho ho più scheda wireless o he pilot giusto, como posso download?

  • Photosmart HP 6510 driver

    Trying to set up this printer HP with my Mac, running OS 10.9. Go to system preferences, select Printers and scanners, click the + to add a printer. I see my printer, select it, and then have three fields below: 1. name, comes up with the default nam

  • Design of bridge of 1300 AP/change

    I have a client w / a 1300 AP filled in two buildings (building A, building B).  Background - building has had Internet, building B does not.  The link was constantly going down, so it was turned off and both sites now have Internet.  From time to ti

  • PIX515-E DMZ clients struggling with WAN web pages

    I have a DMZ behind a PIX515-E configuration that can not display web pages on devices that are managed on the external interface of the firewall. Clients can communicate with the controller without problem, except when the web interface on the PLC i

  • Migration of data from ACS 4.2 to 5.2

    Hi Experts, We have cisco ACS operating with software box 4.2 & 5.2. We want to transfer all the data present in 4.2 5.2 ACS ACS. PL provide me with all the steps I should follow, with the tool that I use for backup. Kind regards Surya.