Get values from a JSON array nested in another array for use in codenameone project using a loop

24 views
Skip to first unread message

Caleb Nasio

unread,
Sep 29, 2014, 5:48:35 PM9/29/14
to codenameone...@googlegroups.com
IDE: NetBeans

I have a JSON array that has two other arrays in it. I would like to retrieve values from both arrays using a loop. the arrays are from a hashed table. Am doing this in a codenameone project. Here is me array from a hashtable:

{2={company=helsana, monthly_amount=100, gender=male, dob=2007, vorname=King, fname=Brian , cid=1, id=2}, 1={company=helsana, monthly_amount=150, gender=female, dob=1985, vorname=King, fname=Lorna, cid=1, id=1}}



Here is my code to get the values so far, which is so not working. Am stuck(I have put "?" where I don't know what to use to get the values). The values are "fname" and "vorname" from the array. 

final String[] anArray;
                 final String[] secArray;
                 anArray = new String[]{String.valueOf(h.get(?))};
                 secArray = new String[]{String.valueOf(h.get(?))};
               
                
                 final Button[] button = new Button[h.size()];
                 for (int i = 0; i < h.size(); i++) {
                    button[i] = new Button(); 
                    button[i].setIcon(fetchResourceFile().getImage("personIconBig.png"));
                    button[i].setText(""+anArray[i]);
                    final String name = String.valueOf(anArray[i]);
                    final String secname = String.valueOf(secArray[i]);
                    
                    button[i].addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {

                        findName().setText(name);
                        findVorname().setText(secname);
                        findFamMname().setText(name+" "+secname);
                        findFamMname().setIcon(fetchResourceFile().getImage("personIconBig.png"));
                        findFamMname2().setText(name+" "+secname);
                        findFamMname2().setIcon(fetchResourceFile().getImage("personIconBig.png"));
                        findDeleteMember().setVisible(true);

                        c.getComponentForm().revalidate();
                        c.getComponentForm().repaint();
               
                        }
                    });




Shai Almog

unread,
Sep 29, 2014, 9:45:51 PM9/29/14
to codenameone...@googlegroups.com
Hi,
use a debugger. Break on that line and expand h in the variable inspector to see the text values.
Reply all
Reply to author
Forward
0 new messages