FORUMS

Catch a emty value or null value?

4 posts
Thanks Meter: 0
 
By pascalbianca, Junior Member on 5th May 2020, 04:09 PM
Post Reply Email Thread
In my program i show with chart from mpandroidchart values from json file taken from a sql table.
The problem is next.
If i get only values then the chart shows fine, but if i get a empty value , nothing is showed.

To catch that i want to make the empty fields 0.

The part that read the values is this.:
Code:
  for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObject = jsonArray.getJSONObject(i);

                    String waarde = jsonObject.getString(waardekeuze);
                    String date = jsonObject.getString(datekeuze);

                 //   if(waarde != null){ Entry values1 = new Entry(0, i);}
                //    else { Entry values1 = new Entry(Float.parseFloat(waarde), i);}

                   Entry values1 = new Entry(Float.parseFloat(waarde), i);
                 //   if(waarde != null && !waarde.isEmpty()){waarde = 0}else{ Entry values1 = new Entry(Float.parseFloat(waarde), i);}


                        yas.add(date);
                    xas.add(values1);
The problem is , if the field waarde is nothing or 0 then i want that the value is always 0, so the chart has a number to plot.
You see that i tryed some things but nothing works.

How can i solve that?
8th May 2020, 07:02 PM |#2  
OP Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by pascalbianca

In my program i show with chart from mpandroidchart values from json file taken from a sql table.
The problem is next.
If i get only values then the chart shows fine, but if i get a empty value , nothing is showed.

To catch that i want to make the empty fields 0.

The part that read the values is this.:

Code:
  for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObject = jsonArray.getJSONObject(i);

                    String waarde = jsonObject.getString(waardekeuze);
                    String date = jsonObject.getString(datekeuze);

                 //   if(waarde != null){ Entry values1 = new Entry(0, i);}
                //    else { Entry values1 = new Entry(Float.parseFloat(waarde), i);}

                   Entry values1 = new Entry(Float.parseFloat(waarde), i);
                 //   if(waarde != null && !waarde.isEmpty()){waarde = 0}else{ Entry values1 = new Entry(Float.parseFloat(waarde), i);}


                        yas.add(date);
                    xas.add(values1);
The problem is , if the field waarde is nothing or 0 then i want that the value is always 0, so the chart has a number to plot.
You see that i tryed some things but nothing works.

How can i solve that?

Solved by my self.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes