Maps JSON data with two data in the list

Hey all,.

Been working with JSON data and informing the lists for a some time now, but im stuck now on a single set of data.

The data structure is the following:

[
     {
          data: {
               children: [ {
                    {}
                    {}
                    {}
               } ]
           }
     }

     {
          data: {
               children: [ {
                    {}
                    {}
                    {}
               } ]
           }
     }
]

The data that I take care of normally contains one of these structures and not 2 as in the above data. So what follows could could work:

                                const QByteArray response(reply->readAll());
        ArrayDataModel *model = new ArrayDataModel();

        bb::data::JsonDataAccess jda;
        QVariantMap results = jda.loadFromBuffer(response).toMap();
        QVariantList children = results["data"].toMap()["children"].toList();

        model->append(children);
        mListView->setDataModel(model);

However, it is now giving me an empty list. So how can I limit the above code to analyze and insert only the 2nd set of JSON data in the list?

Please let me know if it needs to be clarified. Any help is appreciated. Thank you!

Hello

It contains a list of maps. Have you tried something like the following:

bb::data::JsonDataAccess jda;
QVariantList results = jda.loadFromBuffer(response).toList();if (results.size() >= 2){
    QVariantMap secondSet = results.at(1).toMap(); // to get the second map
    QVariantList children = secondSet["data"].toMap()["children"].toList();
    model->append(children);}

Tags: BlackBerry Developers

Similar Questions

  • view the json data in the custom list field

    Hi, I did analysis json and I created the custom list field. Now, I want to display only the data analyzed in my custom list field. I'll post my analyzed data from json and here is the code for my custom list field
    data analyzed.
    I have THREE channels of json and I want to show content tittle and date in the list filed. I'll post the screenshot of my list.

    JSONArray jsnarry = new JSONArray(responce);
                System.out.println("\n--length----- "+jsnarry.length());
                //System.out.println("....................................................=");
                for (int i = 0; i < jsnarry.length(); i++){
    
                    JSONArray inerarray = jsnarry.getJSONArray(i);
                        //System.out.println("\n-inerarray-values----- "+inerarray.getString(i1));
                        String TITTLE = inerarray.getString(1);
                        String CONTENT = inerarray.getString(2);
                        String DATE = inerarray.getString(3);
                                                           System.out.println("TITTLE= "+TITTLE);
                        System.out.println("CONTENT= "+CONTENT);
                        System.out.println("DATE= "+DATE);
    
    }
    

    output

    [0.0] --length----- 2
    [0.0]
    [0.0] -innerarray-length----- 6
    
    [0.0] TITTLE= BJP State President Sanjay Tandon's visit to Amita Shukla's Home
    [0.0] CONTENT=  BJP President Chandigarh Sanjay Tandon at Amita Shukla's Home
    [0.0] DATE= 2013-01-04
    [0.0] ................................................
    [0.0] TITTLE= Sanjay Tandon at mahasamadhi of Satya Shri Sai baba.
    [0.0] CONTENT= BJP Chandigarh President, Sanjay Tandon mahasmadhi of Sri Satya Sai Baba.(Andhra Pradesh)
    [0.0] DATE= 2013-01-13
    

    and my custom list field

           super(NO_VERTICAL_SCROLL);
    
             String TITTLE="TITTLE";
             String CONTENT = "CONTENT";
             String DATE = "DATE";
    
             v.addElement(new ListRander(listThumb, TITTLE, CONTENT,DATE, navBar));
    
             myListView = new CustomListField(v){
    
                 protected boolean navigationClick(int status, int time) {
                     //Dialog.alert(" time in milisec :" + time);
                     return true;
                 }
             };
    

    CustomListField.java

    public class CustomListField extends ListField implements ListFieldCallback {
    
        private Vector _listData;
        private int _MAX_ROW_HEIGHT = 100;
    
        public CustomListField (Vector data) {
    
            _listData = data;
            setSize(_listData.size());
            setSearchable(true);
            setCallback(this);
            setRowHeight(_MAX_ROW_HEIGHT);
    
        }
    
        public int moveFocus (int amount, int status, int time) {
    
            this.invalidate(this.getSelectedIndex());
            return super.moveFocus(amount, status, time);
    
        }
    
        public void onFocus (int direction) {
    
            super.onFocus(direction);
    
        }
    
        protected void onUnFocus () {
    
            this.invalidate(this.getSelectedIndex());
    
        }
    
        public void refresh () {
    
            this.getManager().invalidate();
    
        }
    
        public void drawListRow (ListField listField, Graphics graphics, int index, int y, int w) {
    
            ListRander listRander = (ListRander)_listData.elementAt(index);
            graphics.setGlobalAlpha(255);
            graphics.setFont(Font.getDefault().getFontFamily().getFont(Font.PLAIN, 24));
            final int margin =5;
    
            final Bitmap thumb= listRander.getListThumb();
            final String listHeading = listRander.getListTitle();
            final String listDesc= listRander.getListDesc();
            final String listDesc2= listRander.getListDesc2();
            final Bitmap nevBar = listRander.getNavBar();
    
            //list border
            graphics.setColor(Color.BLACK);
            graphics.drawRect(0, y, w, _MAX_ROW_HEIGHT);
    
            graphics.drawBitmap(margin, y+margin+10, thumb.getWidth(), thumb.getHeight(), thumb, 0, 0);
    
            graphics.drawText(listHeading, 3*margin+thumb.getWidth(), y+margin);
            graphics.setColor(Color.BLACK);
    
            graphics.drawText(listDesc, 3*margin+thumb.getWidth(), y+ margin+30);
            graphics.drawText(listDesc2, 3*margin+thumb.getWidth(), y+ margin+60);
    
        }
    
        public Object get(ListField listField, int index) {
    
            String rowString = (String) _listData.elementAt(index);
            return rowString;
    
        }
    
        public int indexOfList (ListField listField, String prefix, int start) {
    
            for (Enumeration e = _listData.elements(); e.hasMoreElements(); ) {
    
                String rowString = (String) e.nextElement();
                if (rowString.startsWith(prefix)) {
    
                    return _listData.indexOf(rowString);
    
                }
    
            }
    
            return 0;
    
        }
    
        public int getPreferredWidth(ListField listField) {
    
            return 3 * listField.getRowHeight();
    
        }
    
    }
    

    Listrander.Java

    public class ListRander {}

    private bitmap listThumb = null;
    incognito bar Bitmap = null;
    private String listTitle = null;
    private String listDesc = null;
    private String listDesc2 = null;

    public ListRander (Bitmap listThumb, String listTitle, String listDesc, String listDesc2, Bitmap navBar) {}
    this.listDesc = listDesc;
    this.listDesc2 = listDesc2;
    this.listThumb = listThumb;
    this.listTitle = listTitle;
    this.navBar = bar navigation;
    }
    public getListThumb() {Bitmap image
    Return listThumb;
    }
    {} public void setListThumb (listThumb Bitmap)
    this.listThumb = listThumb;
    }
    public getNavBar() {Bitmap image
    return the navigation bar;
    }
    {} public void setNavBar (navigation bar of the Bitmap)
    this.navBar = bar navigation;
    }
    public String getListTitle() {}
    Return listTitle;
    }
    {} public void setListTitle (String listTitle)
    this.listTitle = listTitle;
    }
    public String getListDesc() {}
    Return listDesc;
    }
    {} public void setListDesc (String listDesc)
    this.listDesc = listDesc;
    }
    public String getListDesc2() {}
    Return listDesc2;
    }
    public void setListDesc2 (String listDesc2) {}
    this.listDesc2 = listDesc2;
    }
    }

    You seem to have two problems here and are confusing them.  You must break the problem into two parts

    (1) extract the data from the entry and create the objects you want to display

    2) display in a list, a set of objects.

    Let's get the sorted first premiera.

    I will suggest what to do here, but in practice, you might actually think about this yourself as part of the design phase of your application.  You should do this, not me, because then you will have all the information available.  At the present time, I have just what you said, which is not much.  So maybe what I'm telling you is not correct for your application.  Only you can decide that.  And be blunt here, you should have decided this before you start coding.  Do you want you could lead down the wrong path.  You must think of your application as a home - as the architect must design all the rooms, and how they will be built, before you start building the House.  You do not, then we are building the rooms on the fly.  Who knows if they will be fit at home?

    In this case, I think you need to create an object that represents each of the elements in the internal array of new data.  call this object

    NewsItem

    This object will have attributes, such as its title, content, date, the linked image and so on, each of whom have will get and set methods.  While you treat each inner element fetch you the associated entry and update the object.

    When you have finished the inner loop of processing, you now have a complete

    NewsItem

    Object, so you will add it to a collection, an array of NewsItem objects, call this _newsItems.  You will create it at the beginning - you know how many entries it takes because it is the number of entries in your outdoor table.

    So before you start to deal with JSON, create your table and the 'index' value of 0.

    Once you have created your Newsitem, add this in the table to the position 'index' and increment "index".

    And once you have analyzed all the JSON, you will have a complete picture.  This is part 1 finished!

    And note in your drawListRow, you are given a clue - that is the index in your tables in _newsItems.  So you can easily find which entry to view and display it correctly.  But it is part 2 and is a separate issue.

  • The data in the list scrolling

    Hello world

    I use the normal list in my app, bt the problem is that the width of the list item.

    I have no problem with the list in landscape bt from potrait extra mode "".. "". are coming instead of data,

    Is it possible to scroll through the data in the list, (average is the width exceed then automatically the data in the list will scroll,)

    someone can help me. urgnt iam waitng...

    Thanks in advance

    I found the solution which equavalent to scroll.

    I'm overiding method of label in the cell renderer class and applying the marquee event it is great it possible to scroll.

  • You can play with two players on the same conlsoe on modern war

    XXXXXXXXXXXXXX

    Hi Capcurt,

    Welcome to the Microsoft Answers site!

    You try to play the game live with 2 players on the same console?

    Unfortunately, you can not go online with two people on the same console. Modern Warfare 2 allows a user to sign in when you play in multiplayer.

    Modern Warfare 2 is a completely new game mode that supports 2-player cooperative play in single line of the solo campaign in history. To do this, you will need two machines.

    For better support, you can contact Xbox Forums.

    http://www.xbox360forum.com/Forum/

    Hope this information is useful.

    Amrita M

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • When you add pictures to the Vista image folder it creates a folder HIDDEN of the same name with two copies of the same image inside

    I use Vista 32 bit. I started to see this problem when I recently copy photos from an SD card.

    When you add pictures to the Vista image folder it creates a folder HIDDEN of the same name with two copies of the same image inside

    I saw hidden files enabled in folder options.

    Any help is appreciated.

    Hey guys... I found the answer... Problem is with the software vaio content analyzer that comes with the vaio...

    It just search for Vaio Content Analyzer (parameters) and deselect

    Video analysis
    image analysis
    analysis of the music

    I went looking for this crazy thing... used almost all types of online scan, and finally to find that it is caused by an internal software only...
    anyway thanks to all... Hope it helps someone in the future :)
  • Number shaped with two digits "behind the point" :-)

    Hello

    Please excuse my very bad English because I'm french :-)

    I use the beta JDE v4.7 and the Blackberry Storm Simulator included.

    I would like to know how to format a calculated result as #. # (a floating-point value with two digits "behind the point') to display in a RichTextField instance.

    I tried this:

    """"
    String strSomme;
    String strSommeTTC;
    Double dblSomme;
    Double dblSommeTTC;
                   
    strSomme = saisieField.getText ();
                   
    dblSomme = Double.parseDouble (strSomme);
    dblSommeTTC = dblSomme * 119,6 / 100.0;
     
    Trainer fmt = new Formatter();
     
    strSommeTTC = fmt.formatNumber(dblSommeTTC,2);
     
    RichTextField affichageField = new RichTextField ("sum TTC:" + strSommeTTC, Field.NON_FOCUSABLE);
    Add (affichageField);
    """"
     
    Only the small portion of code compiles fine but I get an exception when you run the program in the Simulator: javax.microedition.global.UnsupportedLocaleException

    I don't know if the Formatter class is the best way to convert a 45.528652541 to 45.53 number for example.

    Thanks for any help.

    Nice day.

    Marc

    I ended up writing a method to do this...

        final static String toString(double sum)
        {
            // Turn random double into a clean currency format (ie 2 decimal places)
            StringBuffer result;
    
            if (Math.abs(sum) < .01)
            {
                result = new StringBuffer("0.00");
            }
            else
            {
                if (sum > 0)
                    sum = sum + 0.005;
                else
                    sum = sum - 0.005;
                result = new StringBuffer(Double.toString(sum));
                final int point = result.toString().indexOf('.');
                if (point > 0)  // If has a decimal point, may need to clip off after 2 decimal places
                {
                    if (point < (result.length()-2))  // eg "3.1415"
                    {
                        result =  new StringBuffer(result.toString().substring(0,point+3));
                    }
                }
            }
            return result.toString();
        }
    

    I would like to know if there is a better way!

  • Can I convert a ppt file to PDF with PDF Pack with two blades to the page?

    I want to convert a ppt file to pdf format with two blades on the page, rather than a slide page. I can do this with a printer. How do I do this with pdf pack?

    Hi sandyd,.

    When you convert PowerPoint to PDF via Adobe PDF Pack, it will convert each slide in the deck to a page in the PDF file. Unfortunately, there is no way to change this.

    Best,

    Sara

  • What is the name of the circular icon with two swings in the content panel?

    Adobe Bridge CS5

    Win 7 Pro 64-bit

    What is the name of the circular icon with two swings in the Panel content above the thumbnail image of a raw file? I can't find documentation about it.

    Thanks in advance.

    Thanks for the keyword "badge".

    With that, I found it's called a

    "Badge of parameters.

    There is also a badge of culture which has an icon of culture.

  • Qosmio G50 PQG55A: remote control jumps two places in the list of the menu of WMC

    I have a version of the G50 (PQG55A-04J01Y) Aust and have just done a clean install of Windows 7 (64-bit).
    Everyone thinks that when using the provided Toshiba RC6 remote in Windows Media Center, it jumps two places in the list of the menu.

    I downloaded the driver Winbond CIR, Win7, but it makes no difference.

    Very annoying as it does on all manu lists and even ignores the channels while watching TV.

    Someone at - he seen elsewhere or have a possible solution?

    See you soon

    There is a package called Remote Control Manager.
    This driver is required to install the remote control of your computer.

    The package is only for Vista, but maybe you should try to install too

  • Maps of data in the program generator

    Hello

    I have a program type of default members corresponding to data cards. I want to feed new data cards in this program regularly. How can I add the cards given to this program?

    Also, I need to create a decision rule for comparing a value filed in touch and then update the contact field. The following types of two actions are visible in the steps of the action 'compare the contact and update contact fields'. How can I associate the data card with contacts?

    Thank you

    Rama

    If you need check a value stored against a custom data object, then using contact with the field of the linked custom object has a filter would be the way to go.

    You can use it as your feeder program comes to create contacts as the default member type and allow maps of data of your choice set to be admitted to the program.

    If you need set the value of a field of contact (IE on the contact record) to "1" then it's simple, if you are looking to update a field on the custom data object with a new value, then you can use the submit form cloud connector and use a "blind" form submission , use it create / update custom data object stage of the process to update your custom with new value "1" data subject field.

    Make sense?

  • How to extract string in JSON data where the value in a table

    Hello

    Structure of JSON string

    {'name': 'John', 'name': 'kumar', 'address': [{'Address1': 'value', 'place': 'value'}, {'address2': 'value', 'place': 'value'}]}

     


    How to extract the value of the address of the list.

    If you have control over the format of data, it is best to rename address1 and address2 to have the same name, for example "address". Then, it can be analyzed that way (I've also simplified other code a bit):

    JsonDataAccess jda;
    QVariant v = jda.loadFromBuffer(jsonString);
    QVariantMap m = v.toMap();
    QString name = m["name"].toString();
    QString surname = m["surname"].toString();
    QVariantList addresses = m["address"].toList();
    foreach (QVariant addr, addresses)
    {  QVariantMap addrMap = addr.toMap();
      QString addressValue = addrMap["address"].toString();
      QString place = addrMap["place"].toString();
    }
    
  • Google Maps and Mapviewer with SRID 8307 like the SRID display.

    LJ recently published the very concise example (thanks!) of the google maps display in mapviewer on his blog.

    Questions to which I am soliciting answers to form the forum is:

    (1) for the use of Google map tiles, is the assumption that made the SRID for the card will, or should be SRID 3785?
    (2) the ability to google does support the tiles from google to be crushed on a map of mapviewer with SRID 8307 upward? (I ask because we tried and we have the offset of the scale - perhaps zoom levels must be set to 20?)

    Thank you

    Stone

    Not that I know of. Used 3785 and 11.1.0.6, 11.1.0.7 without problems.

    Send me msg of error MapBuilder.
    And entry of user_sdo_geom_metadata for the table, the column that contains the data in 3785.

  • variable with two digits after the point

    Hi all

    How can I specify variable to work with two numbers (one, three) after the point?

    e.q.

    Set one to 3.14159265358 like (lack of knowledge here)

    return a

    3.14 returned must

    It is a two-step process:

    Set A to 3.14159265358

    Set A (round (A * 100)) / 100

    The 100 can be changed as needed.

    (144176)

  • Loading data into the list when necessary

    HI all,

    I'm a huge display of data from database in the list,

    I do not want to load all the data in one shot, I want to show also responsible, means (if the user scroll the list automatically loads the data from my db?)

    any ideas?

    Thank you

    You will need to check whether sqlite supports offsets and limits.

    http://www.SQL.org/SQL-database/PostgreSQL/manual/queries-limit.html

  • record data in the list control

    Hi all

    I changed a program a list item in a list control of "51" "77" by using the function NOR "ReplaceListItem (...)"

    When I left the program and looked at the list control, I have observed the list item has still "51" (instead of the expected '77').

    The question is: ' how can I permanently replace a list item in a list control.

    Thank you.

    Bob

    If I understand correctly, you have defined some items in the list control in IUR Editor, then you want to change one of them by program and have this change in the file of the IUR.

    Well, if that's what you are trying to accomplish, there is no easy way to get it: operated by program changes cancel their scope when you exit the program and not reflected in the physical files. Use the ICB ActiveX interface, save the IUR in TUI form with function (CVI_AppConvertUIRToTUI), modify programmatically the TUI file, save it and then convert it to the IUR by CVI_AppConvertTUIToUIR () format. Not a trivial task, I'm afraid, and, possibly, this task is not worth.

    An easier way is to have an external options file or a configuration file where to store items to load in the list control when you need it: this file can be edited by yourself, either programmatically or manually when you need to change some items.

Maybe you are looking for

  • Portege S100: How to change the RAID in the BIOS

    Change the BIOS setting for Portege S100 of JBOD to RAID0, I hit space on Exectute creation and enter the key of type string in the manual, and press "enter".Settings and then return to existing arrangements and not the new RAID0 configuration settin

  • Pure SKU custom

    I'm looking to design my own bike X Pure, but I would like to use it with the radio of the Republic. If I make a Moto X Pure with the manufacturer of motorcycle online and order it, what will be the SKU? Wireless Republic said that it must be XT1575.

  • HP Envy 15-J009WM w / no CD/DVD drive

    Hello- I just replaced my old PC with a new laptop HP Envy, which I was love until I discovered it is not a CD/DVD drive at all. (It does not have a card reader). It's common these days or I buy a bad model? I have the camera software and some photos

  • Widows 7

    I chose an earlier date in December for my PC settings back. Now my PC looks like its in mode safe and all the fonts & everything is twice the size, and only about half of my screen is used. Microsoft wanted to $99, but I am on disability and my inju

  • Compatibility of the sony ic recorder software and drivers with windows 7. 64 bit__

    Program downloads, when I start it, I get a message telling me the program is not responding and must stop.This message comes immediately after the graphics and such fact and it is immediately not functional.I tried the program compatibility Wizard t