Back to project page NoiseBridge_General.
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.
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"); } }