The analysis of json format

main.cpp

/*
 * Copyright (c) 2011-2013 BlackBerry Limited.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include 

#include 
#include 
#include "applicationui.hpp"

#include 

using namespace bb::cascades;

Q_DECL_EXPORT int main(int argc, char **argv)
{
    Application app(argc, argv);

    // Create the Application UI object, this is where the main.qml file
    // is loaded and the application scene is set.
    new ApplicationUI(&app);

    // Enter the application main event loop.
    return Application::exec();
}

applicationui.cpp

#include "applicationui.hpp"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include "timer.h"

using namespace bb::cascades;
using namespace bb::data;

ApplicationUI::ApplicationUI(bb::cascades::Application *app) :
        QObject(app)
{

    Page *root = new Page;
    ListView *listView = new ListView;
    Container *topContainer = new Container;
    Label *errorLabel = new Label;
    // Create the data model, specifying sorting keys of "firstName" and "lastName"
    GroupDataModel *model = new GroupDataModel(QStringList() << "firstName"
                                               << "lastName");

    // Create a JsonDataAccess object and load the .json file. The
    // QDir::currentPath() function returns the current working
    // directory for the app.
    JsonDataAccess jda;
    QVariant list = jda.load(QDir::currentPath() +
                             "/app/native/assets/employees.json");

    // Determine if an error occurred during the load() operation
    if (jda.hasError()) {
        // Retrieve the error
        DataAccessError theError = jda.error();

        // Determine the type of error that occurred
        if (theError.errorType() == DataAccessErrorType::SourceNotFound)
            errorLabel->setText("Source not found: " + theError.errorMessage());
        else if (theError.errorType() == DataAccessErrorType::ConnectionFailure)
            errorLabel->setText("Connection failure: " + theError.errorMessage());
        else if (theError.errorType() == DataAccessErrorType::OperationFailure)
            errorLabel->setText("Operation failure: " + theError.errorMessage());
    } else {
        errorLabel->setText("No error.");
    }
    // Insert the data into the data model. Because the root of the .json file
    // is an array, a QVariant(QVariantList) is returned from load(). You can
    // provide a QVariantList to a data model directly by using insertList().
    model->insertList(list.value());

    listView->setDataModel(model);
    root->setContent(listView);
    app->setScene(root);
}

void ApplicationUI::onSystemLanguageChanged()
{
    QCoreApplication::instance()->removeTranslator(m_pTranslator);
    // Initiate, load and install the application translation files.
    QString locale_string = QLocale().name();
    QString file_name = QString("SplashSceen_%1").arg(locale_string);
    if (m_pTranslator->load(file_name, "app/native/qm")) {
        QCoreApplication::instance()->installTranslator(m_pTranslator);
    }
}

When I open the application, the application gives me the white page.  Employees.JSON is located in the assets folder

OK simon, thanks a lot.

I solved the error, someone in front of me he met too

http://supportforums.BlackBerry.com/T5/native-development/A-simple-example-of-populating-data-from-J...

its an error in the json file on the sample applications.

Tags: BlackBerry Developers

Similar Questions

  • Save the analysis in PDF format

    I want to scan and save a document in pdf format. However, the Windows settings, Scan & Fax appear only to allow me to save in files such as JPEG picture, etc. I can't find a way to change the settings. Help please!

    As Malke said... also, if your scanning software does not support scanning to PDF you may be interested in Scan to PDF software ofhttp://www.softi.co.uk/ (I recently evaluated this software for use of clients).   It works well but costs $29.99, there is a free 30-day trial.  I have not found a free or shareware equivalent that works reliably.

    "Robertc1969" wrote in the new message: * e-mail address is removed from the privacy... *

    I want to scan and save a document in pdf format. However, the Windows settings, Scan & Fax appear only to allow me to save in files such as JPEG picture, etc. I can't find a way to change the settings. Help please!

  • The analysis of GPX Format

    Hello. If someone managed to analyze the gpx XML data. The XML looks like this:

    < gpx version = "1.1" creator = "Explorer of Trail Mobile" >
    < trk >
    < trkseg >
    < trkpt lat = lon "51.539498" = "-0.488798" >
    < model > 31.5 < / ele >
    < time > 2007-11-30T 13: 07:03Z < / time >
    < / trkpt >
    < / trk >
    < / gpx >

    so far, my analysis function looks like this:

    public static void parseGPS(journey:FileStream):ArrayCollection {}
    var gpe:GPSEntry = new GPSEntry();
    var ac:ArrayCollection = new ArrayCollection();
    var str:String = journey.readUTFBytes (journey.bytesAvailable);
    var XML = XML (str);
    var trkptLength:Number = xml.childNodes [0] Sublst.ChildNodes(1).ChildNodes(0) [0].childNodes.length;
    var gpsTagCnt:Number = 3;
    var trackpointArr:Array = new Array (gpsTagCnt);

    for (var i: uint = 0; i < trkptLength; i ++) {}
    trackpointArr = new Array (gpsTagCnt);
    var now_trkpt:XML = xml.childNodes [0] Sublst.ChildNodes(1).ChildNodes(0) [0] Sublst.ChildNodes(1).ChildNodes(0)
    ;
    trackpointArr [0] = now_trkpt.attributes.lat;
    trackpointArr
    [1] = now_trkpt.attributes.lon;
    trackpointArr [2] = now_trkpt.childNodes [0] .firstChild;
    trackpointArr
    [3] = now_trkpt.childNodes [1] .firstChild;

    GPE. ELE = trackpointArr [2];
    GPE.lat trackpointArr =
    [0];
    GPE.long = trackpointArr [1];
    GPE. Time = trackpointArr
    [3];

    ac.addItem (gpe);
    }

    return ac;

    }


    The file stream is passed from the mxml application. It returns a collection of table to display in a datagrid

    I managed to do it. Here is the answer.

    public static void parseGPS(journey:FileStream):ArrayCollection {}

    var ac:ArrayCollection = new ArrayCollection();
    var str:String = journey.readUTFBytes (journey.bytesAvailable);
    var XML = XML (str);
    xml.ignoreWhite = true;
    var node: XMLList = xml.children ();
    var trkptLength:Number = nodes.children () [0] .children () .length ();

    for (var i: Number = 0; i
    var gpe:GPSEntry = new GPSEntry();
    GPE.lat = nodes.children () [0] .children () .@lat;
    GPE.long = nodes.children () [0] .children ()
    .@lon;
    GPE. ELE = nodes.children () [0] ( ) .children. children() [0];
    GPE. Time = nodes.children () [0] .children ()
    . children() [1];

    ac.addItem (gpe);
    }

    return ac;

    }

  • The analysis of lists in PL/JSON

    I'm working on parsing a json string that is stored in a CLOB table in oracle 11g. This process belongs to a long analysis of routine which analyzes the data and stores the values in another table, and I just noticed that part of my data is not out. The json analysis and valid with JSONLint. So I simplified the analysis to try to find out where I'm wrong.

    So my json out of my table looks like this.

    {

    'JSON_data': {}

    "plant_id": "3006."

    "transmit_time": "2015-12-18 11:57:45."

    'messages': [{}

    'work_msg': {}

    "msg_time": "2015-06-23 04:54:17", ".

    "trigger_type':"interval. "

    'vert_correction': 358,3,

    'ch_latitude': 37.916302,

    'ch_longitude':-87.487365,

    'ch_heading': 212,3,.

    'ch_cable_port': 1029.79,

    'ch_cable_stbd': 348.63,.

    'ch_depth':-27.03,

    'slurry_velocity': 25.71,.

    'slurry_density': 1.02,.

    'ch_rpm': 205.49,.

    'ch_psi': 540.89.

    'prod_instantaneous': 0,

    'prod_cumulative': 1216.100000,

    'outfall_latitude': 37.915967,

    'outfall_longitude':-87.484369,

    'outfall_heading': 120,7,.

    "pump_entries": [{}

    'pump_name': 'main ',.

    'empty': 12.73.

    'outlet_psi': 22,88

    }],

    "spud_entries": [{}

    'position': 6

    }]

    },

    'pipe_length_event': {}

    "msg_time": "2015-06-23 04:54:17", ".

    "length_floating": 970

    }

    }]

    }

    }

    My analysis is properly find and do his thing with the data "work_msg". It's the data 'pipe_length_event' that I don't get to. Here is my pl/sql procedure.

    DECLARE

    vCONTENT CLOB.
    v_parent_json json;
    v_json_message_list json_list;
    v_json_message_list_value json_value;
    v_parent_json_value json_value;

    BEGIN

    SELECT CONTENT IN SJM_TEMP4 vCONTENT;

    v_parent_json: = json (vCONTENT);
    v_parent_json: = json (v_parent_json.get (1));

    v_json_message_list: = json_list (v_parent_json.get ('messages'));

    DBMS_OUTPUT. Put_line (v_json_message_list. (Count);

    for message_loop_counter in 1... loop v_json_message_list. Count
    v_parent_json_value: = json (v_json_message_list.get (message_loop_counter)) .get (1);

    If v_parent_json_value.mapname = "work_msg" then
    DBMS_OUTPUT. Put_line ('FOUND: work_msg');
    on the other
    DBMS_OUTPUT. Put_line (v_parent_json_value.mapname);
    end if;

    END LOOP;

    END;

    My dbms_output first gives me a sublist from 1 account. 2. not so my analysis does not yet recognize the 'pipe_length_event' as a sublist of "messages".

    How can I get data 'pipe_length_event' by using this procedure? I am almost sure that it worked in the past, so my first thought is that json is formatted differently. Is the json in the wrong format?

    Thanks in advance.

    They moved their forums to StackOverflow.  I had posted my question there before here.  In any case, I found my own answer.  JSON is not properly formatted.  The 'work_msg' was not closed correctly, and "pipe_length_event" has not been opened in a new list.  So once I had that all squared away he analysed very well.

    For reference, the correct formatting is below.

    {

    'JSON_data': {}

    "plant_id": "3006."

    "transmit_time": "2015-12-18 11:57:45."

    'messages': [{}

    'work_msg': {}

    "msg_time": "2015-06-23 04:54:17", ".

    "trigger_type':"interval. "

    'vert_correction': 358,3,

    'ch_latitude': 37.916302,

    'ch_longitude':-87.487365,

    'ch_heading': 212,3,.

    'ch_cable_port': 1029.79,

    'ch_cable_stbd': 348.63,.

    'ch_depth':-27.03,

    'slurry_velocity': 25.71,.

    'slurry_density': 1.02,.

    'ch_rpm': 205.49,.

    'ch_psi': 540.89.

    'prod_instantaneous': 0,

    'prod_cumulative': 1216.100000,

    'outfall_latitude': 37.915967,

    'outfall_longitude':-87.484369,

    'outfall_heading': 120,7,.

    "pump_entries": [{}

    'pump_name': 'main ',.

    'empty': 12.73.

    'outlet_psi': 22,88

    }],

    "spud_entries": [{}

    'position': 6

    }]

    }

    }, {

    'pipe_length_event': {}

    "msg_time": "2015-06-23 04:54:17", ".

    "length_floating": 970

    }

    }]

    }

    }

  • I want to move the bookmarks to a no start Win disk (format jspn) to win 10 PC. The import dialog box wants html, not json format

    the motherboard on my old PC to WIn 7 has become damaged. I took the hard e drive: toward a new win 10 PC. I can find the Archives of bookmark on the old disk - files are in json format, but when I try to import the bookmarks file I can only find a way to import them into html format. How do I resolve this condition glare?

    If the file is in json format, then it replaces the current file.

    To open the bookmark, Manager press the ALT or F10 to rise
    the tool, then select bookmarks.
    Access key is < Control >(Mac = < Command >) < shift > B.

    Once the window is open, the top of the page, press the button
    Import and backup. Select export bookmarks to HTML and follow
    prompts and save it in a HTML file. Copy the file to another computer.
    Repeat the above instructions, BUT select Import Bookmarks in HTML,

    JSON files. Do as above, but select restore. The file must be in the
    Bookmarks backup folder.

  • I am trying to edit music digitized using Adobe Acrobat DC on a Lenovo tablet, Windows 7 operating system.  Adobe Acrobat DC rejects the analysis as unchangeable.  I export to a word document and re-export to AADC in pdf format.  It will then allow to cul

    Hello.  I'm currently editing digital music pdf using Adobe Acrobat DC on a Lenovo tablet with Windows 7 operating system.  Adobe Acrobat rejects the analysis as unchangeable.  I export the scanned pdf to MS Word and re-export to AADC in pdf format.  This can be cropped, but the edit function does not allow the movement of the measures (or 'skin measures text') within a team.  I am producing pages with 3 litters per page and 3 measures by staff who can be sufficiently enlarged to a blind musician.  My failure to change the measures so far means there is too much information by page and the page can be expanded properly. Advice please.  Thank you.  Charles.

    This is well beyond what Acrobat is intended - not just a little far, but a lot. PDF is therefore completely inappropriate for this.

    Address bits scan and cutting/organizing her before making a PDF. Maybe in Photoshop.

  • On Mac, how to scan multiple pages to a pdf file using the analysis of the glass?

    Mac OS x v10. 7, how to set up analysis of the HP Officejet 6500 multiple pages in a single pdf of the file by using the analysis of the glass?

    I couldn't find the box uncheck the box to 'Save as individual file' to the Mac.

    My reccomendation is to use the Image Capture in your Applications folder.  Choose your scanner to the left, then click on "Show details" on the bottom.

    Choose the PDF format, then check the box for "combine several pages into single file" (or similar words).

  • The analysis of the non-numeric characters in a string

    Hello

    I am communicating a robot to LabVIEW (2013) via TCP/IP and sockets. The robot is the server, and LV is the customer.

    I start with the target data in this format (in a string):

    "[0 ~ 100 ~ 0] ~ [0.96593 ~-0.25882 ~ 0 ~ 0] ~ [1 ~ 0 ~ 0 ~ 0] ~ [150 ~ 50]."

    [X, Y, Z], [Q1, Q2, Q3, Q4], [C1, C4, C6, Cx], [TCPVel, OrientVel] except replacement ',' (comma) with a ' ~ ' (tilde) because I load the target data in a spreadsheet which is a comma-delimited file.

    In LV, I take this string, the analysis of the chain and split individual items. I then pulled the singular elements as unique, 32-bit of real numbers. I take each one and convert them individually to a string, concatenate them and send them to the robot. The robot decompresses these raw bytes individually and converts them to a target of robot (position in space).

    I train (BT) check if the user has sent a bad character (non-digital) in the target data. Example of this is:

    [- 50 ~-150 ~ 0] ~ [0.96593 ~-0 ] [B2has5D882 ~ 0 ~ 0] ~ [1 ~-1 ~ 0 ~ 0] ~ [150 ~ 50]

    Now in BT, when I'm scanning the chain, these bad character becomes the entire element to zero and everything else then to zero as well. See attachment for example screen similar.

    My question is, my VI, I can analyze all non-numeric characters (that are inside the parentheses and characters that are NOT a ' ~ ' (tilde))? In this way, I can always get this item numbers and do not have this element or other items turn to zero?

    Thanks in advance for any help!

    Sorry for the question of the test

    SM


  • Anyone who works with the CAF (Caltech intermediate Format) files in LabVIEW?

    Hey everybody,

    Anyone who works with the CAF (Caltech intermediate Format) files? These are files that are generated by IC layout programs, such as TannerEDA L-Edit, that define the layers and arrangement of the masks used in VLSI (Photolithography) of processing semiconductor device.

    I would like to analyse these CIF files to generate a map of wafer of devices for use in the-plate test. Currently, a plan of shooting is made and then I manually switch and define coordinates of line and column for the edge of a plate and various places of drop-in. I would like to automate this process, and I don't know if it is possible by playback of these files from the CAF. However, I don't really know how to read them, and I can get as much information from the Wikipedia page and the original article.

    So I ask: anyone has an easier set of screws that make reading CIF file? Or someone working with them can help me with my problem? I can describe it in much better detail once someone comes...

    Here is one of my notebooks CIF of Mathematica (remove the .txt extension obviously).  I used it to create a new CIF file with four instances of the object in a file.

    You can load a file with the following text:

    symName = loadCIF;

    You can see the layers:

    CIFlayers [symName]

    You can view layers:

    Show [{viewCIFlayer [symName, #, color of layer]}]

    (if you wish, add multiple layers to the list)

    If you have a file of type CIF I can also test to see that it recognizes the objects you use, I am generally to polygons and boxes.

  • Sending page apex to the application process (JSON) values

    Hi all

    A page 5 apex has a value in a hidden item, P5_CLASS
    In the apex 5 page, I wrote a JavaScript to call for a process of application (PL/SQL) to retrieve the values of a table on Page 5.
    var ajaxRequest = new htmldb_Get (null, & APP_ID., 'APPLICATION_PROCESS is Get_Class_Data', 0);
    and I use the JSON object to display the rows in the table.
    -----------
    Problem
    -----------
    It works pretty well. But I need to send the value of the hidden element P5_CLASS to Get_Class_Data so that I can ask P5_CLASS-basedapplication process.

    Help, please.

    Shiva says:
    Thank you Paul,.

    So I can use

    var ajaxRequest = new htmldb_Get (null, & APP_ID, 'APPLICATION_PROCESS = GET_CLASS_DATA', 0);
    ajaxRequest.add ('F15_GLOBALVAR', $v ("#P5_CLASS")) to send the value to the application process?

    (F15_GLOBALVAR is an application-level element, I created in the shared components)

    And to use this application in my sql in GET_CLASS_DATA, I can use sql... where class =: F15_GLOBALVAR?

    Yes.

    (Please zip code wrapped in \

    ...\
    

    Tags to preserve the special characters and formatting.)

  • the analysis of data from a legacy in the form of bytes bluetooth

    Hi, Iam execution of java for MYGlucoHealth code monitor. I have to catch the bluetooth through my application data and analyze format. (later I store in the SQLite database). But according to the specification of the Protocol had, I do not understand how to read and analyze. I know how to pair the device to my request. But I do not know how to parse the bytes of data according to the Protocol of the device specification.

    Can someone tell me how to do this. All done with this kind of coding?

    Thnaks in advance,

    -Cissokho

    Published by: 798686 on November 2, 2010 02:38

    798686 wrote:
    Ok.. Thank you

    Tips for the facilitator: don't double post. I've locked the new thread.
    the analysis of data from a legacy in the form of bytes bluetooth
    Please continue here.

    DB

  • Download the video in MPG format to iCloud photo library

    Is it possible to download a video file, MPG to a Mac to iCloud photo library?

    I stopped using iCloud photo library on the Mac due to low disk space, however I always use iCloud photo library on other devices and would like to have the video available here. I tried to use the web interface to iCloud by using Safari, but I get a message that the format is not supported

    I guess I could convert the file in another format, however, I do not want 3rd party applications on my Mac, and I worry about compromising video quality. Is the other way to do this? Could using Photos (1.5) on the Mac and the activation of my photo stream get the video to appear in the photo library of iCloud?

    As we told you MPG is not a format alternative for ICPL

    Types of files that you can use with iCloud photo library

    Your photos and videos are stored in iCloud, exactly as you took them. All your images are in their original format in full resolution, JPEG, RAW, PNG, GIF, TIFF, and MP4, as well as special formats capture you with your iPhone, like slo - mo, Time lapse video 4K and Live Photos.

    iCloud photo library - Apple Support

    LN

  • All of my received emails suddenly changed to the 'Source of the Message' (no HTML) format. How to change their return?

    All of my emails has suddenly changed format in the 'Source of the Message' (no HTML) format. Upcoming new suddenly is back in HTML. Is it possible to convert the received messages to HTML?
    Example of one of them-

    Of the - Thu Feb 19 13:12:54 2015
    X key account: account 1
    X-UIDL: 0MFJMQ-1YIimi1UiS-00ETqm
    X-Mozilla-Status: 0001
    X-Mozilla-Status2: 00000000
    X-Mozilla-keys:
    Return-Path: bounce-857_HTML-206598685-987434-260085-83038@bounce.global.expediamail.com
    Received: from mta.quotitmail.com ([66.231.85.77]) by mx.perfora.net

    (mxeueus001) with ESMTPS (Nemesis) id 0MFJMQ-1YIimi1UiS-00ETqm for
    <[email protected]>; Thu, 19 Feb 2015 01:35:36 +0100
    

    DKIM signature: v = 1; a = rsa-sha1; c = relaxed/relaxed; s = 200608; d =expediamail.com;

    h=From:To:Subject:Date:MIME-Version:Reply-To:Message-ID:Content-Type:Content-Transfer-Encoding; [email protected];
    bh=fNo3DAi3AhVqqOOcWiTDUbWFywc=;
    b=N429V9jQXRGv6C7+5HaLPGqlcgG/TcpFOhv0/Qb8NzGYhs0ZsvLsSmpmxyKD/mdaFhGePrNUpaAP
      +jen5myxsUX3lbr064O2a21h66NUjMHB785XH0FEV6JKm3QdW1u+KHz0szgaxy1CtUSZQk3gjlP1
      MOo6DXu7PV0u0oEd77Q=
    

    Thank you

    Right click on the folder, select Properties, and then on the button repair.

    Be sure to create an exception in your anti-virus analyzes the Thunderbird profile folder.

  • How can I recharge my favorites if I can't find the file "date.json" in my backup?

    My hard drive crashed and everything had to be recovered and reinstalled. I have a data folder Firefox but can not find the file "date.json" which is indicated to open the troubleshooting instructions. Y at - it another option?

    Hello

    If you have the latest version of Firefox, the file places.sqlite is what keeps your bookmarks. See the article for recovery of data from an old profile for more information.

  • How can I adjust the settings of Firefox to display the content in a format widescreen?

    How can I adjust the settings of Firefox to display the content in a format widescreen?

    You mean zoom? If so, check the module NoSquint .

Maybe you are looking for