List of usage examples for android.util JsonReader skipValue
public void skipValue() throws IOException
From source file:com.workday.autoparse.json.demo.ParserAnnotatedObjectParser.java
private void parseFromReader(ParserAnnotatedObject out, JsonReader reader) throws IOException { final String discriminationName = ContextHolder.getContext().getSettings().getDiscriminationName(); while (reader.hasNext()) { String name = reader.nextName(); if (discriminationName.equals(name)) { out.discriminationValue = JsonParserUtils.nextString(reader, discriminationName); continue; }//w ww .ja v a 2s . c o m switch (name) { case "string": { out.string = reader.nextString(); break; } default: { reader.skipValue(); } } } }
From source file:com.example.propertylist.handler.JsonPropertyHandler.java
/** * Populates property data with the JSON data. * * @param reader//w ww . java 2 s. co m * the {@link android.util.JsonReader} used to read in the data * @return * the propertyResults * @throws org.json.JSONException * @throws java.io.IOException */ public List<Property> populateResultsSales(JsonReader reader) throws JSONException, IOException { List<Property> propertyResults = new ArrayList<Property>(); reader.beginObject(); while (reader.hasNext()) { final String name = reader.nextName(); final boolean isNull = reader.peek() == JsonToken.NULL; if (name.equals("results") && !isNull) { propertyResults = populateAdsSales(reader); } else { reader.skipValue(); } } reader.endObject(); return propertyResults; }
From source file:com.example.propertylist.handler.JsonPropertyHandler.java
/** * Populates property data with the JSON data. * * @param reader//from w w w. j a v a2 s.com * the {@link android.util.JsonReader} used to read in the data * @return * the propertyResults * @throws org.json.JSONException * @throws java.io.IOException */ public List<Property> populatePropertySales(JsonReader reader) throws JSONException, IOException { // Property property = new Property(); List<Property> propertyResults = new ArrayList<Property>(); reader.beginObject(); while (reader.hasNext()) { final String name = reader.nextName(); final boolean isNull = reader.peek() == JsonToken.NULL; if (name.equals("result") && !isNull) { propertyResults = populateResultsSales(reader); } else { reader.skipValue(); } } reader.endObject(); return propertyResults; }
From source file:fiskinfoo.no.sintef.fiskinfoo.Http.BarentswatchApiRetrofit.BarentswatchApi.java
public BarentswatchApi() { String directoryPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) .toString();/*from w w w . j av a 2s . c o m*/ String fileName = directoryPath + "/FiskInfo/api_setting.json"; File file = new File(fileName); String environment = null; if (file.exists()) { InputStream inputStream; InputStreamReader streamReader; JsonReader jsonReader; try { inputStream = new BufferedInputStream(new FileInputStream(file)); streamReader = new InputStreamReader(inputStream, "UTF-8"); jsonReader = new JsonReader(streamReader); jsonReader.beginObject(); while (jsonReader.hasNext()) { String name = jsonReader.nextName(); if (name.equals("environment")) { environment = jsonReader.nextString(); } else { jsonReader.skipValue(); } } jsonReader.endObject(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } } targetProd = !"pilot".equals(environment); currentPath = targetProd ? barentsWatchProdAddress : barentsWatchPilotAddress; BARENTSWATCH_API_ENDPOINT = currentPath + "/api/v1/geodata"; Executor httpExecutor = Executors.newSingleThreadExecutor(); MainThreadExecutor callbackExecutor = new MainThreadExecutor(); barentswatchApi = initializeBarentswatchAPI(httpExecutor, callbackExecutor); }
From source file:at.ac.tuwien.caa.docscan.logic.DataLog.java
private GPS readGPS(JsonReader reader) throws IOException { String longitude = null;//from ww w .j a v a 2 s . com String latitude = null; reader.beginObject(); // reader.beginArray(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals(GPS_LONGITUDE_NAME)) longitude = reader.nextString(); else if (name.equals(GPS_LATITUDE_NAME)) latitude = reader.nextString(); else reader.skipValue(); } // reader.endArray(); reader.endObject(); GPS gps = null; if (longitude != null && latitude != null) gps = new GPS(longitude, latitude); return gps; }
From source file:com.tcity.android.ui.info.BuildArtifactsTask.java
private void handleFiles(@NotNull JsonReader reader) throws IOException { reader.beginArray();/* w w w . j a v a2 s . com*/ List<BuildArtifact> result = new ArrayList<>(); while (reader.hasNext()) { reader.beginObject(); long size = -1; String name = null; String contentHref = null; String childrenHref = null; while (reader.hasNext()) { switch (reader.nextName()) { case "size": size = reader.nextLong(); break; case "name": name = reader.nextString(); break; case "children": childrenHref = getHref(reader); break; case "content": contentHref = getHref(reader); break; default: reader.skipValue(); } } if (name == null) { throw new IllegalStateException("Invalid artifacts json: \"name\" is absent"); } if (contentHref == null && childrenHref == null) { throw new IllegalStateException("Invalid artifacts json: \"content\" and \"children\" are absent"); } result.add(new BuildArtifact(size, name, contentHref, childrenHref)); reader.endObject(); } reader.endArray(); myResult = result; }
From source file:com.example.propertylist.handler.JsonPropertyHandler.java
/** * Loads the next observation into the property class. * * @param reader//from w w w . j av a2 s . c o m * the {@link android.util.JsonReader} containing the observation * @throws java.io.IOException */ private Property parseSalesData(JsonReader reader) throws IOException { Property property = new Property(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("full_address") && reader.peek() != JsonToken.NULL) { property.setFullAddress(reader.nextString()); } else if (name.equals("daft_url") && reader.peek() != JsonToken.NULL) { property.setDaftPropertyUrl(reader.nextString()); } else if (name.equals("description") && reader.peek() != JsonToken.NULL) { property.setDescription(reader.nextString()); } else if (name.equals("small_thumbnail_url") && reader.peek() != JsonToken.NULL) { property.setThumbnailUrl(reader.nextString()); } else if (name.equals("medium_thumbnail_url") && reader.peek() != JsonToken.NULL) { property.setMediumThumbnailUrl(reader.nextString()); } else if (name.equals("large_thumbnail_url") && reader.peek() != JsonToken.NULL) { property.setLargeThumbnailUrl(reader.nextString()); } else { reader.skipValue(); } // end if hasnext } // end while reader.endObject(); return property; }
From source file:com.fuzz.android.limelight.util.JSONTool.java
/** * @param reader//from ww w . j ava2s . c o m * @return the generated Act object from the JSON * @throws IOException */ public static Act readAct(JsonReader reader) throws IOException { int id = -1; String message = null; int messageResId = -1; int graphResId = -1; boolean isActionBarItem = false; double xOffset = -1; double yOffset = -1; int textColor = -1; int textBackgroundColor = -1; float textSize = -1; boolean textBackgroundTransparent = false; String animation = null; String activityName = null; reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("id")) id = reader.nextInt(); else if (name.equals("message")) message = reader.nextString(); else if (name.equals("message_res_id")) messageResId = reader.nextInt(); else if (name.equals("graphic_res_id")) graphResId = reader.nextInt(); else if (name.equals("is_action_bar_item")) isActionBarItem = reader.nextBoolean(); else if (name.equals("x_offset")) xOffset = reader.nextDouble(); else if (name.equals("y_offset")) yOffset = reader.nextDouble(); else if (name.equals("text_color")) textColor = reader.nextInt(); else if (name.equals("text_background_color")) textBackgroundColor = reader.nextInt(); else if (name.equals("text_size")) textSize = reader.nextLong(); else if (name.equals("text_background_transparent")) textBackgroundTransparent = reader.nextBoolean(); else if (name.equals("animation")) animation = reader.nextString(); else if (name.equals("activity_name")) activityName = reader.nextString(); else reader.skipValue(); } reader.endObject(); Act act = new Act(); act.setId(id); act.setMessage(message); act.setMessageResID(messageResId); act.setGraphicResID(graphResId); act.setIsActionBarItem(isActionBarItem); act.setDisplacement(xOffset, yOffset); act.setTextColor(textColor); act.setTextBackgroundColor(textBackgroundColor); act.setTextSize(textSize); act.setTransparentBackground(textBackgroundTransparent); act.setAnimation(animation); act.setActivityName(activityName); act.getLayout(); return act; }
From source file:br.com.thinkti.android.filechooserfrag.fragFileChooserQuizlet.java
private List<RowData> openPage() throws Exception { this.errorDescription = null; this.errorTitle = null; List<RowData> list = new ArrayList<RowData>(); InputStream inputStream = null; try {//from w w w.jav a 2s. c o m if (!blnPrivate) { URL url = new URL(getCatalogUrl()); /*HttpURLConnection connection = (HttpURLConnection) url.openConnection(); if ( connection.getResponseCode() >= 400 ) { inputStream = connection.getErrorStream(); } else { inputStream = connection.getInputStream(); }*/ inputStream = org.liberty.android.fantastischmemo.downloader.quizlet.lib.makeApiCall(url, _main.QuizletAccessToken); } else { inputStream = org.liberty.android.fantastischmemo.downloader.quizlet.lib .getUserPrivateCardsets(_main.QuizletUser, _main.QuizletAccessToken); } JsonReader reader = new JsonReader(new InputStreamReader(inputStream, "UTF-8")); if (!blnPrivate) { reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if ("total_pages".equals(name)) { this.totalPages = reader.nextInt(); if (page > totalPages) { } } else if ("total_results".equals(name)) { this.totalResults = reader.nextInt(); } else if ("page".equals(name)) { this.page = reader.nextInt(); } else if ("error_title".equals(name)) { errorTitle = reader.nextString(); } else if ("error_description".equals(name)) { errorDescription = reader.nextString(); } else if ("sets".equals(name)) { getSets(reader, list); } else { reader.skipValue(); } } reader.endObject(); } else { getSets(reader, list); } } finally { if (inputStream != null) { inputStream.close(); } } return list; }
From source file:br.com.thinkti.android.filechooserfrag.fragFileChooserQuizlet.java
RowData parseSetJson(JsonReader reader) throws IOException { reader.beginObject();//from w w w.j av a2s . c om RowData rowData = new RowData(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("title")) { rowData.name = reader.nextString(); } else if (name.equals("description")) { rowData.description = reader.nextString(); if (rowData.description.length() > 200) rowData.description = rowData.description.substring(0, 100); } else if (name.equals("id")) { rowData.id = reader.nextInt(); } else if (name.equals("term_count")) { rowData.numCards = reader.nextInt(); } else if (name.equals("modified_date")) { long value = reader.nextLong(); rowData.lastModified = Data.SHORT_DATE_FORMAT.format(new Date(value * 1000)); Log.d(Data.APP_ID, " modified_date value=" + value + " formatted=" + rowData.lastModified + " now=" + (new Date().getTime())); } else { reader.skipValue(); } } reader.endObject(); return rowData; }