Ejemplo n.º 1
1
 /** Peeks at the next token and returns a {@link Double} or {@code null} */
 Double nextNumberOrNull() throws IOException {
   if (_reader.peek() == JsonToken.NULL) {
     _reader.nextNull();
     return null;
   }
   return _reader.nextDouble();
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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();
 }
Ejemplo n.º 4
0
  public ArrayList<Promotion> parsePromotionList(JsonReader jsonReader) {
    ArrayList<Promotion> promoList = new ArrayList<Promotion>();

    try {
      jsonReader.beginObject();
      while (jsonReader.hasNext()) {
        String name = jsonReader.nextName();
        if (name.equals(JSON_KEY_PROMOTIONS) && jsonReader.peek() != JsonToken.NULL) {

          jsonReader.beginArray();
          while (jsonReader.hasNext()) {
            Promotion promo = parsePromotion(jsonReader);
            if (promo != null) {
              promoList.add(promo);
            }
          }
          jsonReader.endArray();

        } else {
          jsonReader.skipValue();
        }
      }
      jsonReader.endObject();

    } catch (IOException e) {
    }

    return promoList;
  }
Ejemplo n.º 5
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public ArrayList<Song> parseSongList(JsonReader jsonReader) {
    ArrayList<Song> songList = new ArrayList<Song>();

    try {
      jsonReader.beginObject();
      while (jsonReader.hasNext()) {
        String name = jsonReader.nextName();
        if (name.equals(JSON_KEY_RESULTS) && jsonReader.peek() != JsonToken.NULL) {

          jsonReader.beginArray();
          while (jsonReader.hasNext()) {
            Song song = parseSong(jsonReader);
            if (song != null) {
              songList.add(song);
            }
          }
          jsonReader.endArray();

        } else {
          jsonReader.skipValue();
        }
      }
      jsonReader.endObject();

    } catch (IOException e) {
    }

    return songList;
  }
Ejemplo n.º 6
0
 /** Peeks at the next token and returns a {@link Boolean} or {@code null} */
 Boolean nextBooleanOrNull() throws IOException {
   if (_reader.peek() == JsonToken.NULL) {
     _reader.nextNull();
     return null;
   }
   return _reader.nextBoolean();
 }
 /** Consumes {@code expected}. */
 private void expect(JsonToken expected) throws IOException {
   peek();
   if (token != expected) {
     throw new IllegalStateException("Expected " + expected + " but was " + peek());
   }
   advance();
 }
  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();
    }
  }
Ejemplo n.º 9
0
  /** Peeks at the next token and returns a {@link org.json.JSONObject} or {@code null} */
  JSONObject nextObjectOrNull() throws IOException {
    if (_reader.peek() == JsonToken.NULL) {
      _reader.nextNull();
      return null;
    }
    JSONObject json = new JSONObject();
    String name;
    Object value;
    _reader.beginObject();
    while (_reader.hasNext()) {
      name = _reader.nextName();
      switch (_reader.peek()) {
        case STRING:
          value = nextStringOrNull();
          break;
        case BEGIN_ARRAY:
          value = nextArrayOrNull();
          break;
        case BEGIN_OBJECT:
          value = nextObjectOrNull();
          break;
        case BOOLEAN:
          value = nextBooleanOrNull();
          break;
        case NUMBER:
          value = nextNumberOrNull();
          break;
        case NULL:
          _reader.nextNull();
          value = null;
          break;
        default:
          _reader.skipValue();
          value = null;
      }
      try {
        json.put(name, value);
      } catch (JSONException e) {
        Log.e(
            getClass().getSimpleName(),
            "Failed to parse JSON object: " + name + ", value = " + value);
      }
    }
    _reader.endObject();

    return json;
  }
Ejemplo n.º 10
0
  /**
   * Consumes the next token from the JSON stream and asserts that it is a literal null.
   *
   * @throws IllegalStateException if the next token is not null or if this reader is closed.
   */
  public void nextNull() throws IOException {
    peek();
    if (token != JsonToken.NULL) {
      throw new IllegalStateException("Expected null but was " + token);
    }

    advance();
  }
Ejemplo n.º 11
0
 @SuppressWarnings("cast")
 public static some.test.Booleans createUsingJsonStream(Realm realm, JsonReader reader)
     throws IOException {
   some.test.Booleans obj = realm.createObject(some.test.Booleans.class);
   reader.beginObject();
   while (reader.hasNext()) {
     String name = reader.nextName();
     if (name.equals("done")) {
       if (reader.peek() == JsonToken.NULL) {
         reader.skipValue();
         throw new IllegalArgumentException("Trying to set non-nullable field 'done' to null.");
       } else {
         ((BooleansRealmProxyInterface) obj).realmSet$done((boolean) reader.nextBoolean());
       }
     } else if (name.equals("isReady")) {
       if (reader.peek() == JsonToken.NULL) {
         reader.skipValue();
         throw new IllegalArgumentException("Trying to set non-nullable field 'isReady' to null.");
       } else {
         ((BooleansRealmProxyInterface) obj).realmSet$isReady((boolean) reader.nextBoolean());
       }
     } else if (name.equals("mCompleted")) {
       if (reader.peek() == JsonToken.NULL) {
         reader.skipValue();
         throw new IllegalArgumentException(
             "Trying to set non-nullable field 'mCompleted' to null.");
       } else {
         ((BooleansRealmProxyInterface) obj).realmSet$mCompleted((boolean) reader.nextBoolean());
       }
     } else if (name.equals("anotherBoolean")) {
       if (reader.peek() == JsonToken.NULL) {
         reader.skipValue();
         throw new IllegalArgumentException(
             "Trying to set non-nullable field 'anotherBoolean' to null.");
       } else {
         ((BooleansRealmProxyInterface) obj)
             .realmSet$anotherBoolean((boolean) reader.nextBoolean());
       }
     } else {
       reader.skipValue();
     }
   }
   reader.endObject();
   return obj;
 }
Ejemplo n.º 12
0
 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();
 }
Ejemplo n.º 13
0
  /** Advances the cursor in the JSON stream to the next token. */
  private JsonToken advance() throws IOException {
    peek();

    JsonToken result = token;
    token = null;
    value = null;
    name = null;
    return result;
  }
Ejemplo n.º 14
0
 /**
  * Returns the next token, a {@link JsonToken#NAME property name}, and consumes it.
  *
  * @throws IOException if the next token in the stream is not a property name.
  */
 public String nextName() throws IOException {
   peek();
   if (token != JsonToken.NAME) {
     throw new IllegalStateException("Expected a name but was " + peek());
   }
   String result = name;
   advance();
   return result;
 }
Ejemplo n.º 15
0
  /**
   * Returns the {@link JsonToken#STRING string} value of the next token, consuming it. If the next
   * token is a number, this method will return its string form.
   *
   * @throws IllegalStateException if the next token is not a string or if this reader is closed.
   */
  public String nextString() throws IOException {
    peek();
    if (token != JsonToken.STRING && token != JsonToken.NUMBER) {
      throw new IllegalStateException("Expected a string but was " + peek());
    }

    String result = value;
    advance();
    return result;
  }
Ejemplo n.º 16
0
  /**
   * Returns the {@link JsonToken#NUMBER double} value of the next token, consuming it. If the next
   * token is a string, this method will attempt to parse it as a double using {@link
   * Double#parseDouble(String)}.
   *
   * @throws IllegalStateException if the next token is not a literal value.
   */
  public double nextDouble() throws IOException {
    peek();
    if (token != JsonToken.STRING && token != JsonToken.NUMBER) {
      throw new IllegalStateException("Expected a double but was " + token);
    }

    double result = Double.parseDouble(value);
    advance();
    return result;
  }
Ejemplo n.º 17
0
  /**
   * Returns the {@link JsonToken#BOOLEAN boolean} value of the next token, consuming it.
   *
   * @throws IllegalStateException if the next token is not a boolean or if this reader is closed.
   */
  public boolean nextBoolean() throws IOException {
    peek();
    if (token != JsonToken.BOOLEAN) {
      throw new IllegalStateException("Expected a boolean but was " + token);
    }

    boolean result = (value == TRUE);
    advance();
    return result;
  }
Ejemplo n.º 18
0
  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();
  }
  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);
  }
Ejemplo n.º 20
0
 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());
   }
 }
Ejemplo n.º 21
0
  /** Peeks at the next token and returns a {@link List} or {@code null} */
  List nextArrayOrNull() throws IOException {
    if (_reader.peek() == JsonToken.NULL) {
      _reader.nextNull();
      return null;
    }
    _reader.beginArray();
    Object value = null;
    List arr = new ArrayList();

    while (_reader.hasNext()) {
      switch (_reader.peek()) {
        case STRING:
          value = nextStringOrNull();
          break;
        case BEGIN_ARRAY:
          value = nextArrayOrNull();
          break;
        case BEGIN_OBJECT:
          value = nextObjectOrNull();
          break;
        case BOOLEAN:
          value = nextBooleanOrNull();
          break;
        case NUMBER:
          value = nextNumberOrNull();
          break;
        case NULL:
          _reader.nextNull();
          value = null;
          break;
      }
      arr.add(value);
    }
    _reader.endArray();
    return arr;
  }
Ejemplo n.º 22
0
  /**
   * Returns the {@link JsonToken#NUMBER int} value of the next token, consuming it. If the next
   * token is a string, this method will attempt to parse it as an int. If the next token's numeric
   * value cannot be exactly represented by a Java {@code int}, this method throws.
   *
   * @throws IllegalStateException if the next token is not a literal value.
   * @throws NumberFormatException if the next literal value cannot be parsed as a number, or
   *     exactly represented as an int.
   */
  public int nextInt() throws IOException {
    peek();
    if (token != JsonToken.STRING && token != JsonToken.NUMBER) {
      throw new IllegalStateException("Expected an int but was " + token);
    }

    int result;
    try {
      result = Integer.parseInt(value);
    } catch (NumberFormatException ignored) {
      double asDouble = Double.parseDouble(value); // don't catch this NumberFormatException
      result = (int) asDouble;
      if ((double) result != asDouble) {
        throw new NumberFormatException(value);
      }
    }

    advance();
    return result;
  }
Ejemplo n.º 23
0
  /**
   * Returns the {@link JsonToken#NUMBER long} value of the next token, consuming it. If the next
   * token is a string, this method will attempt to parse it as a long. If the next token's numeric
   * value cannot be exactly represented by a Java {@code long}, this method throws.
   *
   * @throws IllegalStateException if the next token is not a literal value.
   * @throws NumberFormatException if the next literal value cannot be parsed as a number, or
   *     exactly represented as a long.
   */
  public long nextLong() throws IOException {
    peek();
    if (token != JsonToken.STRING && token != JsonToken.NUMBER) {
      throw new IllegalStateException("Expected a long but was " + token);
    }

    long result;
    try {
      result = Long.parseLong(value);
    } catch (NumberFormatException ignored) {
      double asDouble = Double.parseDouble(value); // don't catch this NumberFormatException
      result = (long) asDouble;
      if ((double) result != asDouble) {
        throw new NumberFormatException(value);
      }
    }

    advance();
    return result;
  }
Ejemplo n.º 24
0
 public static SatsClass createUsingJsonStream(Realm realm, JsonReader reader) throws IOException {
   SatsClass obj = realm.createObject(SatsClass.class);
   reader.beginObject();
   while (reader.hasNext()) {
     String name = reader.nextName();
     if (name.equals("id") && reader.peek() != JsonToken.NULL) {
       obj.setId((String) reader.nextString());
     } else if (name.equals("centerFilterId") && reader.peek() != JsonToken.NULL) {
       obj.setCenterFilterId((String) reader.nextString());
     } else if (name.equals("classTypeId") && reader.peek() != JsonToken.NULL) {
       obj.setClassTypeId((String) reader.nextString());
     } else if (name.equals("durationInMinutes") && reader.peek() != JsonToken.NULL) {
       obj.setDurationInMinutes((int) reader.nextInt());
     } else if (name.equals("instructorId") && reader.peek() != JsonToken.NULL) {
       obj.setInstructorId((String) reader.nextString());
     } else if (name.equals("name") && reader.peek() != JsonToken.NULL) {
       obj.setName((String) reader.nextString());
     } else if (name.equals("startTime") && reader.peek() != JsonToken.NULL) {
       obj.setStartTime((String) reader.nextString());
     } else if (name.equals("bookedPersonsCount") && reader.peek() != JsonToken.NULL) {
       obj.setBookedPersonsCount((int) reader.nextInt());
     } else if (name.equals("maxPersonsCount") && reader.peek() != JsonToken.NULL) {
       obj.setMaxPersonsCount((int) reader.nextInt());
     } else if (name.equals("regionId") && reader.peek() != JsonToken.NULL) {
       obj.setRegionId((String) reader.nextString());
     } else if (name.equals("waitingListCount") && reader.peek() != JsonToken.NULL) {
       obj.setWaitingListCount((int) reader.nextInt());
     } else if (name.equals("classCategoryIds") && reader.peek() != JsonToken.NULL) {
       reader.beginArray();
       while (reader.hasNext()) {
         se.greatbrain.sats.data.model.ClassCategoryIds item =
             ClassCategoryIdsRealmProxy.createUsingJsonStream(realm, reader);
         obj.getClassCategoryIds().add(item);
       }
       reader.endArray();
     } else {
       reader.skipValue();
     }
   }
   reader.endObject();
   return obj;
 }
Ejemplo n.º 25
0
 /** Returns true if the current array or object has another element. */
 public boolean hasNext() throws IOException {
   peek();
   return token != JsonToken.END_OBJECT && token != JsonToken.END_ARRAY;
 }
    private userVerificationResult parseJSON(JsonReader jsonReader, String urlString)
        throws IOException {
      // int eventType = parser.getEventType();
      userVerificationResult result = new userVerificationResult();
      jsonReader.beginObject();
      while (jsonReader.hasNext()) {
        final String name = jsonReader.nextName();
        final boolean isNull = jsonReader.peek() == JsonToken.NULL;
        if (name.equals("data") && !isNull) {
          jsonReader.beginObject();
          while (jsonReader.hasNext()) {
            final String innerName = jsonReader.nextName();
            final boolean isInnerNull = jsonReader.peek() == JsonToken.NULL;
            if (innerName.equals("pins") && !isInnerNull) {
              jsonReader.beginArray();
              while (jsonReader.hasNext()) {
                jsonReader.beginObject();
                while (jsonReader.hasNext()) {
                  final String innerInnerName = jsonReader.nextName();
                  final boolean isInnerInnerNull = jsonReader.peek() == JsonToken.NULL;
                  if (innerInnerName.equals("description") && !isInnerInnerNull) {
                    result.description.add(jsonReader.nextString());
                  } else if (innerInnerName.equals("images") && !isInnerInnerNull) {
                    jsonReader.beginObject();
                    while (jsonReader.hasNext()) {
                      final String sizeName = jsonReader.nextName();
                      final boolean isSizeNull = jsonReader.peek() == JsonToken.NULL;
                      if (sizeName.equals("237x") && !isSizeNull) {
                        jsonReader.beginObject();
                        while (jsonReader.hasNext()) {
                          final String imageName = jsonReader.nextName();
                          final boolean isImageNull = jsonReader.peek() == JsonToken.NULL;
                          if (imageName.equals("url") && !isImageNull) {
                            result.imageURL.add(jsonReader.nextString());
                          } else {
                            jsonReader.skipValue();
                          }
                        }
                        jsonReader.endObject();
                      } else {
                        jsonReader.skipValue();
                      }
                    }
                    jsonReader.endObject();
                  } else {
                    jsonReader.skipValue();
                  }
                }
                jsonReader.endObject();
              }
              jsonReader.endArray();
            } else {
              jsonReader.skipValue();
            }
          }
          jsonReader.endObject();
        } else if (name.equals("data") && isNull) {
          Toast.makeText(
                  getBaseContext(), "Invalid User. Please try another name.", Toast.LENGTH_LONG)
              .show();
          // onURLError(urlString);

          result.description.add("Invalid");
          result.imageURL.add(urlString);

        } else {
          jsonReader.skipValue();
        }
      }
      jsonReader.endObject();

      return result;
    }
Ejemplo n.º 27
0
 private FoodItem readFoodInfo(JsonReader reader) throws IOException {
   FoodItem food = new FoodItem();
   reader.beginObject();
   while (reader.hasNext()) {
     String name = reader.nextName();
     if (name.equals("item_name") && reader.peek() != JsonToken.NULL) {
       food.setName(reader.nextString());
     } else if (name.equals("brand_name") && reader.peek() != JsonToken.NULL) {
       food.setBrand(reader.nextString());
     } else if (name.equals("nf_serving_size_qty") && reader.peek() != JsonToken.NULL) {
       food.setServingSize(reader.nextDouble());
     } else if (name.equals("nf_serving_size_unit") && reader.peek() != JsonToken.NULL) {
       food.setServingSizeUnit(reader.nextString());
     } else if (name.equals("nf_calories")) {
       if (reader.peek() == JsonToken.NULL) {
         food.setField("Calories", 0.0);
         reader.skipValue();
       } else {
         food.setField("Calories", reader.nextDouble());
       }
     } else if (name.equals("nf_total_fat")) {
       if (reader.peek() == JsonToken.NULL) {
         food.setField("Total Fat", 0.0);
         reader.skipValue();
       } else {
         food.setField("Total Fat", reader.nextDouble());
       }
     } else if (name.equals("nf_sodium")) {
       if (reader.peek() == JsonToken.NULL) {
         food.setField("Sodium", 0.0);
         reader.skipValue();
       } else {
         food.setField("Sodium", reader.nextDouble());
       }
     } else if (name.equals("nf_total_carbohydrate")) {
       if (reader.peek() == JsonToken.NULL) {
         food.setField("Total Carbohydrate", 0.0);
         reader.skipValue();
       } else {
         food.setField("Total Carbohydrate", reader.nextDouble());
       }
     } else if (name.equals("nf_sugars")) {
       if (reader.peek() == JsonToken.NULL) {
         food.setField("Sugars", 0.0);
         reader.skipValue();
       } else {
         food.setField("Sugars", reader.nextDouble());
       }
     } else if (name.equals("nf_protein")) {
       if (reader.peek() == JsonToken.NULL) {
         food.setField("Protein", 0.0);
         reader.skipValue();
       } else {
         food.setField("Protein", reader.nextDouble());
       }
     } else {
       reader.skipValue();
     }
   }
   reader.endObject();
   return food;
 }