Android Open Source - NoiseBridge_General Read Json






From Project

Back to project page NoiseBridge_General.

License

The source code is released under:

GPLv3.txt

If you think the Android project NoiseBridge_General listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.noysbrij.noisebridgeGeneral;
import java.io.*;
import android.util.*;
import android.widget.*;
import java.util.*;
/*from  w  w  w .  j  a va  2s .  c o  m*/
public class ReadJson extends NoiseBridgeGeneral
{
// tickets
    Tickets tickets;
//  count the tickets
  int ticketCount;

   public Tickets readTickets(InputStream in) throws IOException
  {
    ticketCount = -1;
    tickets = new Tickets();
    JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
    try
    {
        reader.beginArray();
      while (reader.hasNext())
      {        
        tickets.tickets.add(new Ticket());
        readTicket(reader);
        
      }
      reader.endArray();
      
    }
    finally
    {
      reader.close();
    }
    return tickets;
  }

  public void readTicket(JsonReader reader) throws IOException
  {
      reader.beginObject();
    while (reader.hasNext())
    {      

      String name = reader.nextName();
      if (name.equals("complexity")&& reader.peek() != JsonToken.NULL)
      {
                tickets.tickets.add(new Ticket());
        tickets.tickets.get(++ticketCount).complexity = reader.nextString();
    //    Log.i("NBG", "complexity: " + tickets.tickets.get(ticketCount).complexity);
      }
      else if (name.equals("created_at")&& reader.peek() != JsonToken.NULL)
      {
        tickets.tickets.get(ticketCount).created_at = reader.nextString();
      }
      else if (name.equals("description")&& reader.peek() != JsonToken.NULL)
      {
        tickets.tickets.get(ticketCount).description = reader.nextString();
      }
      else if (name.equals("do_at")&& reader.peek() != JsonToken.NULL)
      {
        tickets.tickets.get(ticketCount).do_at = reader.nextString();
      }
      else if (name.equals("id")&& reader.peek() != JsonToken.NULL)
      {
    //    Log.i("TAG", "getting id");
        tickets.tickets.get(ticketCount).id = reader.nextInt();
    //    Log.i("TAG", "got id");
      }
      else if (name.equals("owner_id")&& reader.peek() != JsonToken.NULL)
      {
      //  Log.i("TAG", "getting owner id");
        tickets.tickets.get(ticketCount).owner_id = reader.nextInt();
      //  Log.i("TAG", "got owner id");
        
      }
      else if (name.equals("requestor_id")&& reader.peek() != JsonToken.NULL)
      {
        tickets.tickets.get(ticketCount).requestor_id = reader.nextInt();
      }
      else if (name.equals("status")&& reader.peek() != JsonToken.NULL)
      {
        tickets.tickets.get(ticketCount).status = reader.nextString();
      }
      else if (name.equals("ticket_type")&& reader.peek() != JsonToken.NULL)
      {
        tickets.tickets.get(ticketCount).ticket_type = reader.nextString();
      }
      else if (name.equals("title")&& reader.peek() != JsonToken.NULL)
      {
        tickets.tickets.get(ticketCount).title = reader.nextString();
      }
      else if (name.equals("updated_at")&& reader.peek() != JsonToken.NULL)
      {
        tickets.tickets.get(ticketCount).updated_at = reader.nextString();
      //  Log.i("NBG", "updated : " + tickets.tickets.get(ticketCount).updated_at);
      }
      else
      {
        reader.skipValue();
      }
    //  Log.i("NBG", "finisheditem");
    }
    reader.endObject();
  //  Log.i("NBG", "finished read");
    
  }

}




Java Source Code List

com.loopj.android.http.AsyncHttpClient.java
com.loopj.android.http.AsyncHttpRequest.java
com.loopj.android.http.AsyncHttpResponseHandler.java
com.loopj.android.http.BinaryHttpResponseHandler.java
com.loopj.android.http.JsonHttpResponseHandler.java
com.loopj.android.http.PersistentCookieStore.java
com.loopj.android.http.RequestParams.java
com.loopj.android.http.RetryHandler.java
com.loopj.android.http.SerializableCookie.java
com.loopj.android.http.SimpleMultipartEntity.java
com.loopj.android.http.SyncHttpClient.java
com.metamage.noisegate.Completion.java
com.metamage.noisegate.Data.java
com.metamage.noisegate.F.java
com.metamage.noisegate.GetAndDiscardUrlTask.java
com.metamage.noisegate.Key.java
com.metamage.noisegate.Noisegate.java
com.metamage.noisegate.Teletype.java
com.noysbrij.fragments.DatePickerFragment.java
com.noysbrij.fragments.JSInterface.java
com.noysbrij.fragments.ListViewFragment.java
com.noysbrij.fragments.NBWebViewFragment.java
com.noysbrij.fragments.TicketsArrayAdapter.java
com.noysbrij.fragments.TimePickerFragment.java
com.noysbrij.noisebridgeGeneral.NoiseBridgeGeneral.java
com.noysbrij.noisebridgeGeneral.ReadJson.java
com.noysbrij.noisebridgeGeneral.Ticket.java
com.noysbrij.noisebridgeGeneral.TicketsExpandableListAdapter.java
com.noysbrij.noisebridgeGeneral.Tickets.java