コード例 #1
0
  @Override
  public void onMessage(int instanceId, String message) {
    StringReader contents = new StringReader(message);
    JsonReader reader = new JsonReader(contents);

    int requestId = -1;
    String cmd = null;
    String url = null;
    try {
      reader.beginObject();
      while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals(TAG_CMD)) {
          cmd = reader.nextString();
        } else if (name.equals(TAG_REQUEST_ID)) {
          requestId = reader.nextInt();
        } else if (name.equals("url")) {
          url = reader.nextString();
        } else {
          reader.skipValue();
        }
      }
      reader.endObject();
      reader.close();

      if (cmd != null && cmd.equals(CMD_REQUEST_SHOW) && requestId >= 0) {
        handleRequestShow(instanceId, url, requestId);
      }
    } catch (IOException e) {
      Log.d(TAG, "Error: " + e);
    }
  }
コード例 #2
0
ファイル: RepoParser.java プロジェクト: vezikon/Github_Sample
  public Repo readMessage(JsonReader reader) throws IOException {

    repo = new Repo();

    reader.beginObject();
    while (reader.hasNext()) {
      String name = reader.nextName();

      if (name.equals("name")) {
        repo.setName(reader.nextString());
      } else if (name.equals("description")) {
        repo.setDescription(reader.nextString());
      } else if (name.equals("owner")) {
        ReadOwnerMessage(reader);
      } else if (name.equals("html_url")) {
        repo.setRepo_url(reader.nextString());
      } else if (name.equals("fork")) {
        repo.setFork(reader.nextBoolean());
      } else {
        reader.skipValue();
      }
    }
    reader.endObject();
    return repo;
  }
コード例 #3
0
    private FoodResult readHitObject(JsonReader reader) throws IOException {
      FoodResult food = new FoodResult();

      reader.beginObject();
      while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals("_index")) {
          String index = reader.nextString();
          // we currently do nothing with this value
        } else if (name.equals("_type")) {
          String type = reader.nextString();
          // we currently do nothing with this value
        } else if (name.equals("_id")) {
          food.id = reader.nextString();
        } else if (name.equals("_score")) {
          double score = reader.nextDouble();
          // we currently do nothing with this value
        } else if (name.equals("fields")) {
          readHitFields(reader, food);
        } else {
          reader.skipValue();
        }
      }
      reader.endObject();
      return food;
    }
コード例 #4
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public Song parseSong(JsonReader jsonReader) {
    Song song = new Song();

    try {
      jsonReader.beginObject();
      while (jsonReader.hasNext()) {
        String name = jsonReader.nextName();
        if (name.equals(JSON_KEY_TRACKID)) {
          song.setId(jsonReader.nextLong());
        } else if (name.equals(JSON_KEY_ARTISTNAME)) {
          song.setArtist(jsonReader.nextString());
        } else if (name.equals(JSON_KEY_TRACKNAME)) {
          song.setTitle(jsonReader.nextString());
        } else if (name.equals(JSON_KEY_TRACKPRICE)) {
          song.setPrice(jsonReader.nextDouble());
        } else if (name.equals(JSON_KEY_TRACKCOVER)) {
          song.setCoverURL(jsonReader.nextString());
        } else {
          jsonReader.skipValue();
        }
      }
      jsonReader.endObject();

    } catch (IOException e) {
    }

    return song;
  }
コード例 #5
0
ファイル: SnippetsManager.java プロジェクト: xar369/chromium
    private SnippetArticle readArticleDetails(JsonReader reader) throws IOException {
      String headline = "";
      String publisher = "";
      String snippets = "";
      String url = "";
      String thumbnail = "";

      reader.beginObject();
      while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals("headline")) {
          headline = reader.nextString();
        } else if (name.equals("publisher")) {
          publisher = reader.nextString();
        } else if (name.equals("snippet")) {
          snippets = reader.nextString();
        } else if (name.equals("url")) {
          url = reader.nextString();
        } else if (name.equals("thumbnail")) {
          thumbnail = reader.nextString();
        } else {
          reader.skipValue();
        }
      }
      reader.endObject();
      return new SnippetsManager.SnippetArticle(
          headline, publisher, snippets, url, thumbnail, mNumArticles++);
    }
コード例 #6
0
ファイル: JsonParser.java プロジェクト: malditotm/ANF_AS
  public Promotion parsePromotion(JsonReader jsonReader) {
    Promotion promo = new Promotion();

    try {
      jsonReader.beginObject();
      while (jsonReader.hasNext()) {
        String name = jsonReader.nextName();
        if (name.equals(JSON_KEY_BUTTON)) {
          promo.setButton(parseButton(jsonReader));
        } else if (name.equals(JSON_KEY_DESCRIPTION)) {
          promo.setDescription(jsonReader.nextString());
        } else if (name.equals(JSON_KEY_FOOTER)) {
          promo.setFooter(jsonReader.nextString());
        } else if (name.equals(JSON_KEY_TITLE)) {
          promo.setTitle(jsonReader.nextString());
        } else if (name.equals(JSON_KEY_IMAGE)) {
          promo.setImage(jsonReader.nextString());
        } else {
          jsonReader.skipValue();
        }
      }
      jsonReader.endObject();

    } catch (IOException e) {
    }

    return promo;
  }
コード例 #7
0
  private void parseWeatherFormWeather(JsonReader reader) throws IOException {
    Log.d(TAG, "Entering parseWeatherFormWeather");

    reader.beginArray();
    reader.beginObject();
    try {
      while (reader.hasNext()) {
        String name = reader.nextName();
        switch (name) {
          case JsonWeatherTokens.DESCRIPTION:
            weatherData.setWeather(reader.nextString());
            break;
          case JsonWeatherTokens.ICON:
            weatherData.setIcon(reader.nextString());
            break;
          default:
            reader.skipValue();
            break;
        }
      }
    } finally {
      reader.endObject();
      reader.endArray();
    }
  }
コード例 #8
0
  private void readMessage(JsonReader reader) throws IOException {

    String name = null;
    String zone = null;
    String apn = null;
    String address = null;

    reader.beginObject();
    while (reader.hasNext()) {

      tag = reader.nextName();

      if (tag.equals("name")) {
        name = reader.nextString();
      } else if (tag.equals("zone")) {
        zone = reader.nextString();
      } else if (tag.equals("apn")) {
        apn = reader.nextString();
      } else if (tag.equals("address")) {
        address = reader.nextString();
      } else if (tag.equals("feature") && reader.peek() != JsonToken.NULL) {
        polygonPath = readLatLngArray(reader);
      } else {
        reader.skipValue();
      }
    } // while

    reader.endObject();

    // create new marker and polygon
    if (address != null && !address.isEmpty()) {
      address = address + ", COSTA MESA, CA";
    }

    polyopts = new PolygonOptions().addAll(polygonPath);
    polyopts.fillColor(randomColor());
    polyopts.strokeColor(Color.YELLOW);
    polyopts.strokeWidth(1);

    polygon = map.addPolygon(polyopts);

    marker =
        map.addMarker(
            new MarkerOptions()
                .position(polygon.getPoints().get(0))
                .title(address)
                .snippet("APN :[" + apn + "]  Zone : (" + zone + ") ")
                .anchor(0.5f, 0.5f)
                .infoWindowAnchor(0.5f, 0.5f)
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.house2)));
    marker.setVisible(false);
  }
コード例 #9
0
 /** Peeks at the next token and returns a {@link String} or {@code null} */
 String nextStringOrNull() throws IOException {
   if (_reader.peek() == JsonToken.NULL) {
     _reader.nextNull();
     return null;
   }
   return _reader.nextString();
 }
コード例 #10
0
 @SuppressWarnings("cast")
 public static some.test.Simple createUsingJsonStream(Realm realm, JsonReader reader)
     throws IOException {
   some.test.Simple obj = realm.createObject(some.test.Simple.class);
   reader.beginObject();
   while (reader.hasNext()) {
     String name = reader.nextName();
     if (name.equals("name")) {
       if (reader.peek() == JsonToken.NULL) {
         reader.skipValue();
         ((SimpleRealmProxyInterface) obj).realmSet$name(null);
       } else {
         ((SimpleRealmProxyInterface) obj).realmSet$name((String) reader.nextString());
       }
     } else if (name.equals("age")) {
       if (reader.peek() == JsonToken.NULL) {
         reader.skipValue();
         throw new IllegalArgumentException("Trying to set non-nullable field 'age' to null.");
       } else {
         ((SimpleRealmProxyInterface) obj).realmSet$age((int) reader.nextInt());
       }
     } else {
       reader.skipValue();
     }
   }
   reader.endObject();
   return obj;
 }
コード例 #11
0
  /**
   * Parses the raw JSON resource specified by {@code metadataResId}. The JSON is expected to be in
   * this format: { "apiVersion": <version number (string)>, "densities": [ { "density": <density
   * (int)>, "width": <unscaled sprite width (int)>, "height": <unscaled sprite height (int)>,
   * "rectangles": [ [<list of ints for frame 0>], [<list of ints for frame 1>], ...... ] }, {
   * "density": <density (int)>, "width": <unscaled sprite width (int)>, "height": <unscaled sprite
   * height (int)>, "rectangles": [ [<list of ints for frame 0>], [<list of ints for frame 1>],
   * ...... ] }, ...... ] }
   *
   * @param metadataResId The id of the raw resource containing JSON to parse.
   * @param bitmapDensity The density of the unscaled {@link Bitmap} that was loaded.
   * @param resources A {@link Resources} instance to load assets from.
   * @throws IOException
   */
  @VisibleForTesting
  void parseMetadata(int metadataResId, int bitmapDensity, Resources resources) throws IOException {
    InputStream inputStream = resources.openRawResource(metadataResId);
    JsonReader reader = new JsonReader(new InputStreamReader(inputStream));
    try {
      reader.beginObject(); // Start reading top-level object.

      // Check apiVersion.
      String name = reader.nextName();
      assert name.equals("apiVersion");
      String version = reader.nextString();
      assert version.equals("1.0");

      // Parse array of densities.
      name = reader.nextName();
      assert name.equals("densities");
      reader.beginArray(); // Start reading array of densities.
      while (reader.hasNext()) {
        reader.beginObject(); // Start reading object for this density.
        boolean foundDensity = parseMetadataForDensity(reader, bitmapDensity);
        reader.endObject(); // Stop reading object for this density.

        if (foundDensity) break;
      }
    } finally {
      reader.close();
      inputStream.close();
    }
  }
コード例 #12
0
  @Override
  public void onHttpRequestComplete(Intent intent) {
    if (mProgressDialog != null && mProgressDialog.isShowing()) {
      mProgressDialog.dismiss();
    }

    if (intent.getIntExtra(Constants.IntentExtras.REQUEST_ID, -1)
        == Constants.ApiRequestId.GET_EMOJIS_DATA) {

      try {
        String trendingShows = intent.getStringExtra(Constants.IntentExtras.MESSAGE);
        JsonReader jsonReader = new JsonReader(new StringReader(trendingShows));
        jsonReader.beginObject();
        while (jsonReader.hasNext()) {
          String emojisName = jsonReader.nextName();
          String emojisImageUrl = jsonReader.nextString();
          Log.d(getTag(), emojisName + ":" + emojisImageUrl);
          EmojiData emojiData = new EmojiData();
          emojiData.setEmojisName(emojisName);
          emojiData.setEmojisImageUrl(emojisImageUrl);
          emojiDataList.add(emojiData);
        }
        jsonReader.endObject();
        this.emojisListAdapter.notifyDataSetChanged();
      } catch (IOException e) {
        e.printStackTrace();
        Log.e(getTag(), e.getMessage());
      }
    }
  }
コード例 #13
0
ファイル: ShellService.java プロジェクト: nellyv/mojo
 private static String[] getParametersFromIntent(Intent intent) {
   if (intent == null) {
     return null;
   }
   String[] parameters = intent.getStringArrayExtra("parameters");
   if (parameters != null) {
     return parameters;
   }
   String encodedParameters = intent.getStringExtra("encodedParameters");
   if (encodedParameters != null) {
     JsonReader reader = new JsonReader(new StringReader(encodedParameters));
     List<String> parametersList = new ArrayList<String>();
     try {
       reader.beginArray();
       while (reader.hasNext()) {
         parametersList.add(reader.nextString());
       }
       reader.endArray();
       reader.close();
       return parametersList.toArray(new String[parametersList.size()]);
     } catch (IOException e) {
       Log.w(TAG, e.getMessage(), e);
     }
   }
   return null;
 }
コード例 #14
0
 private void parseWeatherFormSys(JsonReader reader) throws IOException {
   Log.d(TAG, "Entering parseWeatherFormSys");
   reader.beginObject();
   try {
     while (reader.hasNext()) {
       String name = reader.nextName();
       switch (name) {
         case JsonWeatherTokens.COUNTRY:
           weatherData.setCountry(reader.nextString());
           break;
         case JsonWeatherTokens.SUNRISE:
           weatherData.setSunrise(reader.nextLong());
           break;
         case JsonWeatherTokens.SUNSET:
           weatherData.setSunset(reader.nextLong());
           break;
         default:
           reader.skipValue();
           break;
       }
     }
   } finally {
     reader.endObject();
   }
 }
コード例 #15
0
  private void parseWeatherServiceResults(JsonReader reader) throws IOException {

    Log.d(TAG, "Entering parse Weather Service Results");
    reader.beginObject();
    try {
      while (reader.hasNext()) {
        String name = reader.nextName();
        switch (name) {
          case JsonWeatherTokens.SYS:
            if (reader.peek() == JsonToken.BEGIN_OBJECT) {
              parseWeatherFormSys(reader);
              break;
            }
          case JsonWeatherTokens.WEATHER:
            parseWeatherFormWeather(reader);
            break;
          case JsonWeatherTokens.MAIN:
            parseWeatherFormMain(reader);
            break;
          case JsonWeatherTokens.WIND:
            parseWeatherFormWind(reader);
            break;
          case JsonWeatherTokens.NAME:
            weatherData.setCity(reader.nextString());
            break;
          default:
            reader.skipValue();
            break;
        }
      }
    } finally {
      reader.endObject();
    }
  }
コード例 #16
0
ファイル: RepoParser.java プロジェクト: vezikon/Github_Sample
  public void ReadOwnerMessage(JsonReader reader) throws IOException {

    reader.beginObject();
    while (reader.hasNext()) {
      String name = reader.nextName();

      if (name.equals("login")) {
        repo.setOwner_name(reader.nextString());
      } else if (name.equals("html_url")) {
        repo.setOwner_url(reader.nextString());
      } else {
        reader.skipValue();
      }
    }

    reader.endObject();
  }
コード例 #17
0
ファイル: JsonParser.java プロジェクト: clsera/Bingo
  public Msg readMsg(JsonReader reader) throws IOException {
    String link = null;
    String text = null;

    reader.beginObject();
    while (reader.hasNext()) {
      String name = reader.nextName();
      if ("link".equals(name)) {
        link = reader.nextString();
      } else if ("text".equals(name)) {
        text = reader.nextString();
      } else {
        reader.skipValue();
      }
    }
    reader.endObject();
    return new Msg(link, text);
  }
コード例 #18
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public static final List<Place> GetPlaces(String source) throws IOException {
    ArrayList<Place> places = new ArrayList<Place>();
    JsonReader reader = null;

    try {
      reader = new JsonReader(new StringReader(source));
      reader.beginArray();
      while (reader.hasNext()) {
        String Code = null;
        String Name = null;
        String HubCode = null;

        reader.beginObject();
        while (reader.hasNext()) {
          String name = reader.nextName();

          if (name.equals("Code")) {
            Code = reader.nextString();
          } else if (name.equals("Name")) {
            Name = reader.nextString();
          } else if (name.equals("HubCode")) {
            HubCode = reader.nextString();
          } else {
            reader.skipValue();
          }
        }
        reader.endObject();

        Place place = new Place();
        place.Code = Code;
        place.Name = Name;
        place.HubCode = HubCode;

        places.add(place);
      }
      reader.endArray();

    } finally {
      if (reader != null) reader.close();
    }

    return places;
  }
コード例 #19
0
ファイル: Conf.java プロジェクト: r7raul1984/RunningX
  public static void read() {
    String filename = String.format(getRootDir() + "/conf.json");
    try {
      FileInputStream fin = new FileInputStream(filename);
      JsonReader reader = new JsonReader(new InputStreamReader(fin, "UTF-8"));

      reader.beginObject();

      // write common information
      while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals("LENGTH_UNIT")) {
          LENGTH_UNIT = reader.nextString();
        } else if (name.equals("MAP_TYPE")) {
          MAP_TYPE = reader.nextString();
        } else if (name.equals("SPEED_TYPE")) {
          SPEED_TYPE = reader.nextString();
        } else if (name.equals("MIN_DISTANCE")) {
          MIN_DISTANCE = reader.nextInt();
        } else if (name.equals("INTERVAL_LOCATION")) {
          INTERVAL_LOCATION = reader.nextInt();
        } else if (name.equals("INTERVAL_LOCATION_FAST")) {
          INTERVAL_LOCATION_FAST = reader.nextInt();
        } else if (name.equals("LOCATION_ACCURACY")) {
          LOCATION_ACCURACY = reader.nextInt();
        } else if (name.equals("SPEED_AVG")) {
          SPEED_AVG = reader.nextInt();
        } else if (name.equals("GPS_ONLY")) {
          GPS_ONLY = reader.nextBoolean();
        } else if (name.equals("GPS_ONLY")) {
          ACCELERATE_FACTOR = (float) reader.nextDouble();
        } else {
          reader.skipValue();
        }
      }
      reader.endObject();

      reader.close();
      fin.close();
    } catch (Exception e) {
      Log.i(TAG, "read conf from file fail.");
    }
  }
コード例 #20
0
 private void readProperties(JsonReader reader) throws IOException {
   String s;
   reader.beginObject();
   while (reader.hasNext()) {
     s = reader.nextName();
     if (s.equals("mag")) {
       magnitude = reader.nextDouble();
     } else if (s.equals("place")) {
       details = reader.nextString();
     } else if (s.equals("detail")) {
       link = reader.nextString();
     } else if (s.equals("time")) {
       date = new Date(Long.parseLong(reader.nextString()));
     } else {
       reader.skipValue();
     }
   }
   reader.endObject();
 }
コード例 #21
0
ファイル: JsonParser.java プロジェクト: malditotm/ANF_AS
  public Button parseButton(JsonReader jsonReader) {
    Button button = new Button();

    try {
      jsonReader.beginObject();
      while (jsonReader.hasNext()) {
        String name = jsonReader.nextName();
        if (name.equals(JSON_KEY_BUT_TARGET)) {
          button.setTarget(jsonReader.nextString());
        } else if (name.equals(JSON_KEY_BUT_TITLE)) {
          button.setTitle(jsonReader.nextString());
        } else {
          jsonReader.skipValue();
        }
      }
      jsonReader.endObject();

    } catch (IOException e) {
    } catch (Exception e) {

      try {
        jsonReader.beginArray();
        jsonReader.beginObject();
        while (jsonReader.hasNext()) {
          String name = jsonReader.nextName();
          if (name.equals(JSON_KEY_BUT_TARGET)) {
            button.setTarget(jsonReader.nextString());
          } else if (name.equals(JSON_KEY_BUT_TITLE)) {
            button.setTitle(jsonReader.nextString());
          } else {
            jsonReader.skipValue();
          }
        }
        jsonReader.endObject();
        jsonReader.endArray();

      } catch (IOException e2) {
      }
    }

    return button;
  }
コード例 #22
0
ファイル: Usuario.java プロジェクト: tomasnfranco/TDP2Grupo9
 private void jsonToUsuario(JsonReader reader) throws JSONException, IOException {
   reader.beginObject();
   while (reader.hasNext()) {
     String name = reader.nextName();
     switch (name) {
       case "id":
         this.id = reader.nextInt();
         break;
       case "token":
         this.token = reader.nextString();
         break;
       case "latitud":
         this.latitud = reader.nextDouble();
         break;
       case "longitud":
         this.longitud = reader.nextDouble();
         break;
       case "activo":
         this.activo = reader.nextBoolean();
         break;
       case "ofreceTransito":
         this.ofreceTransito = reader.nextBoolean();
         break;
       case "autopublicar":
         this.autopublicar = reader.nextBoolean();
         break;
       case "email":
         this.email = reader.nextString();
         break;
       case "username":
         this.username = reader.nextString();
         break;
       case "password":
         this.password = reader.nextString();
         break;
       case "telefono":
         this.telefono = reader.nextString();
         break;
       case "direccion":
         this.direccion = reader.nextString();
         break;
       case "foto":
         if (reader.peek() == JsonToken.NULL) reader.nextNull();
         else {
           this.foto = null;
           reader.nextString();
           // TODO: Completar cuando el post del usuario admita json
           // this.foto.setImg(Imagen.bytesFromBase64DEFAULT(reader.nextString()));
         }
         break;
       default:
         reader.skipValue();
         break;
     }
   }
   reader.endObject();
 }
コード例 #23
0
ファイル: JsonParser.java プロジェクト: clsera/Bingo
  private List<String> readSource(JsonReader reader) throws IOException {
    List<String> source = new ArrayList<>();

    reader.beginArray();
    while (reader.hasNext()) {
      source.add(reader.nextString());
    }
    reader.endArray();

    return source;
  }
コード例 #24
0
ファイル: JsonParser.java プロジェクト: clsera/Bingo
  public Image readImage(JsonReader reader) throws IOException {
    String enddate = null;
    String url = null;
    String copyright = null;
    String copyrightlink = null;
    String hsh = null;
    List<Msg> msgList = new ArrayList<>();
    Vid vid = null;

    reader.beginObject();
    while (reader.hasNext()) {
      String name = reader.nextName();
      if ("enddate".equals(name)) {
        enddate = reader.nextString();
      } else if ("url".equals(name)) {
        url = reader.nextString();
      } else if ("copyright".equals(name)) {
        copyright = reader.nextString();
      } else if ("copyrightlink".equals(name)) {
        copyrightlink = reader.nextString();
      } else if ("hsh".equals(name)) {
        hsh = reader.nextString();
      } else if ("msg".equals(name) && reader.peek() != JsonToken.NULL) {
        msgList.addAll(readMsgs(reader));
      } else if ("vid".equals(name) && reader.peek() != JsonToken.NULL) {
        vid = readVid(reader);
      } else {
        reader.skipValue();
      }
    }
    reader.endObject();
    return new Image.Builder()
        .enddate(enddate)
        .url(url)
        .copyright(copyright)
        .copyrightlink(copyrightlink)
        .hsh(hsh)
        .msg(msgList)
        .vid(vid)
        .build();
  }
コード例 #25
0
  public void deSerializeRepresentation(JsonReader reader) throws IOException {
    ArrayList<String[]> al = new ArrayList<String[]>();
    reader.beginObject();
    while (reader.hasNext()) {
      String[] kv = {reader.nextName(), reader.nextString()};
      al.add(kv);
    }
    reader.endObject();
    String[][] oldFormat = al.toArray(new String[al.size()][]);

    deSerializeRepresentation(oldFormat);
  }
コード例 #26
0
  public static final List<NomenclatureItem> GetNomenclatureItems(String source)
      throws IOException {
    ArrayList<NomenclatureItem> items = new ArrayList<NomenclatureItem>();
    JsonReader reader = null;

    try {
      reader = new JsonReader(new StringReader(source));
      reader.beginArray();
      while (reader.hasNext()) {
        String Code = null;
        String Name = null;

        reader.beginObject();
        while (reader.hasNext()) {
          String name = reader.nextName();

          if (name.equals("Code")) {
            Code = reader.nextString();
          } else if (name.equals("Name")) {
            Name = reader.nextString();
          } else {
            reader.skipValue();
          }
        }
        reader.endObject();

        NomenclatureItem item = new NomenclatureItem();
        item.Code = Code;
        item.Name = Name;

        items.add(item);
      }
      reader.endArray();

    } finally {
      if (reader != null) reader.close();
    }

    return items;
  }
コード例 #27
0
ファイル: Response.java プロジェクト: sni01/Android_Projects
 public Response(JsonReader jsonReader) {
   results = new HashMap<String, String>();
   try {
     jsonReader.beginObject();
     while (jsonReader.peek() != JsonToken.END_OBJECT) {
       String label = jsonReader.nextName();
       results.put(label, jsonReader.nextString());
     }
     jsonReader.endObject();
   } catch (IOException e) {
     Log.i("RESPONSE :", e.getMessage());
   }
 }
コード例 #28
0
ファイル: JsonParser.java プロジェクト: clsera/Bingo
  private Vid readVid(JsonReader reader) throws IOException {
    List<Source> sourceList = new ArrayList<>();
    String image = null;
    String caption = null;

    reader.beginObject();
    while (reader.hasNext()) {
      String name = reader.nextName();
      if ("sources".equals(name)) {
        sourceList.addAll(readSources(reader));
      } else if ("caption".equals(name)) {
        caption = reader.nextString();
      } else if ("image".equals(name)) {
        image = reader.nextString();
      } else {
        reader.skipValue();
      }
    }
    reader.endObject();

    return new Vid.Builder().image(image).caption(caption).sources(sourceList).build();
  }
コード例 #29
0
ファイル: SnippetsManager.java プロジェクト: xar369/chromium
 private void readSnippetGroup(List<SnippetListItem> listSnippetItems, JsonReader reader)
     throws IOException {
   reader.beginObject();
   while (reader.hasNext()) {
     String name = reader.nextName();
     if (name.equals("recommendation_basis")) {
       listSnippetItems.add(new SnippetHeader(reader.nextString()));
     } else if (name.equals("articles")) {
       readArticlesArray(listSnippetItems, reader);
     }
   }
   reader.endObject();
 }
コード例 #30
0
  private Category parseCategory(JsonReader reader) throws IOException {
    String categoryName = "", categoryId = "";
    reader.beginObject();

    while (reader.hasNext()) {
      String name = reader.nextName();
      switch (name) {
        case "CategoryID":
          categoryId = reader.nextString();
          break;
        case "CategoryName":
          categoryName = reader.nextString();
          break;
        default:
          reader.skipValue();
      }
    }

    reader.endObject();
    if (categoryId.equals("-1")) {
      return null;
    }
    return new Category(categoryName, categoryId);
  }