app/src/main/java/com/mensa/zhmensa/services/PollApi.java
/**
     * Converts a JSON Object to a Poll Object
     * @param json
     * @param ctx
     * @return
     */
Converts a JSON Object to a Poll Object
@param json
@param ctx
@return
Converts a JSON Object to a Poll Object @param json @param ctx @return
private static Poll parseJsonEntryToPoll(JsonObject json, Context ctx) {
          Poll poll =  new Poll(json.get("title").getAsString(), "id", Mensa.MenuCategory.from(json.get("mealType").getAsString()), Mensa.Weekday.of(json.get("weekday").getAsNumber().intValue()), json.get("creationdate").getAsString());
          poll.weekday = Mensa.Weekday.of(json.get("weekday").getAsNumber().intValue());
          poll.menuCategory = Mensa.MenuCategory.from(json.get("mealType").getAsString());
          poll.votes = json.get("votecount").getAsNumber().intValue();
          poll.id = json.get("id").getAsString();
          for(JsonElement pollElement : json.getAsJsonArray("options")) {
              JsonObject entry = pollElement.getAsJsonObject();
              String mensaId = entry.get("mensaId").getAsString();
              int votes = entry.get("votes").getAsNumber().intValue();
              poll.addNewOption(entry.get("menuId").getAsString(), mensaId, votes, ctx);
          }
          return poll;
      }
private static Poll parseJsonEntryToPoll ( JsonObject json , Context ctx ) { Poll poll = new Poll ( json . get ( "title" ) . getAsString ( ) , "id" , Mensa . MenuCategory . from ( json . get ( "mealType" ) . getAsString ( ) ) , Mensa . Weekday . of ( json . get ( "weekday" ) . getAsNumber ( ) . intValue ( ) ) , json . get ( "creationdate" ) . getAsString ( ) ) ; poll . weekday = Mensa . Weekday . of ( json . get ( "weekday" ) . getAsNumber ( ) . intValue ( ) ) ; poll . menuCategory = Mensa . MenuCategory . from ( json . get ( "mealType" ) . getAsString ( ) ) ; poll . votes = json . get ( "votecount" ) . getAsNumber ( ) . intValue ( ) ; poll . id = json . get ( "id" ) . getAsString ( ) ; for ( JsonElement pollElement : json . getAsJsonArray ( "options" ) ) { JsonObject entry = pollElement . getAsJsonObject ( ) ; String mensaId = entry . get ( "mensaId" ) . getAsString ( ) ; int votes = entry . get ( "votes" ) . getAsNumber ( ) . intValue ( ) ; poll . addNewOption ( entry . get ( "menuId" ) . getAsString ( ) , mensaId , votes , ctx ) ; } return poll ; }
Converts a JSON Object to a Poll Object
 @param json
 @param ctx
 @return
Converts a JSON Object to a Poll Object @param json @param ctx @return