List of usage examples for com.google.gson JsonObject entrySet
public Set<Map.Entry<String, JsonElement>> entrySet()
From source file:ProcessRequest.java
public void updateTicket(JSONObject recordObject) throws SQLException, JSONException { //check for ticket existence //check for ticket detail existence String valuesPortion = ""; String ticketDate = null;/*from w ww. j a va 2 s. c o m*/ try { ticketDate = mDateFormat .format(new java.util.Date(recordObject.getLong(DbSingleton.TicketSchema.COLUMN_TICKET_DATE))); } catch (JSONException jsone) { ticketDate = recordObject.getString(DbSingleton.TicketSchema.COLUMN_TICKET_DATE); } finally { recordObject.put(DbSingleton.TicketSchema.COLUMN_TICKET_DATE, ticketDate); } String invoiceDate = null; try { invoiceDate = mDateFormat .format(new java.util.Date(recordObject.getLong(DbSingleton.TicketSchema.COLUMN_INVOICE_DATE))); } catch (JSONException jsone) { invoiceDate = recordObject.getString(DbSingleton.TicketSchema.COLUMN_INVOICE_DATE); } finally { recordObject.put(DbSingleton.TicketSchema.COLUMN_INVOICE_DATE, invoiceDate); } String voucherRedeemableDate = null; try { voucherRedeemableDate = mDateFormat.format(new java.util.Date( recordObject.getLong(DbSingleton.TicketSchema.COLUMN_VOUCHER_REDEEMABLE_DATE))); } catch (JSONException jsone) { voucherRedeemableDate = recordObject.getString(DbSingleton.TicketSchema.COLUMN_VOUCHER_REDEEMABLE_DATE); } finally { recordObject.put(DbSingleton.TicketSchema.COLUMN_VOUCHER_REDEEMABLE_DATE, voucherRedeemableDate); } String voucherExpirationDate = null; try { voucherExpirationDate = mDateFormat.format(new java.util.Date( recordObject.getLong(DbSingleton.TicketSchema.COLUMN_VOUCHER_EXPIRATION_DATE))); } catch (JSONException jsone) { voucherExpirationDate = recordObject.getString(DbSingleton.TicketSchema.COLUMN_VOUCHER_EXPIRATION_DATE); } finally { recordObject.put(DbSingleton.TicketSchema.COLUMN_VOUCHER_EXPIRATION_DATE, voucherExpirationDate); } String paymentDate = null; try { paymentDate = mDateFormat .format(new java.util.Date(recordObject.getLong(DbSingleton.TicketSchema.COLUMN_PAYMENT_DATE))); } catch (JSONException jsone) { paymentDate = recordObject.getString(DbSingleton.TicketSchema.COLUMN_PAYMENT_DATE); } finally { recordObject.put(DbSingleton.TicketSchema.COLUMN_PAYMENT_DATE, paymentDate); } String trailerLastTareDate = null; try { trailerLastTareDate = mDateFormat.format(new java.util.Date( recordObject.getLong(DbSingleton.TicketSchema.COLUMN_TRAILER_LAST_TARE_DATE))); } catch (JSONException jsone) { trailerLastTareDate = recordObject.getString(DbSingleton.TicketSchema.COLUMN_TRAILER_LAST_TARE_DATE); } finally { recordObject.put(DbSingleton.TicketSchema.COLUMN_TRAILER_LAST_TARE_DATE, trailerLastTareDate); } String truckLastTareDate = null; try { truckLastTareDate = mDateFormat.format( new java.util.Date(recordObject.getLong(DbSingleton.TicketSchema.COLUMN_TRUCK_LAST_TARE_DATE))); } catch (JSONException jsone) { truckLastTareDate = recordObject.getString(DbSingleton.TicketSchema.COLUMN_TRUCK_LAST_TARE_DATE); } finally { recordObject.put(DbSingleton.TicketSchema.COLUMN_TRUCK_LAST_TARE_DATE, truckLastTareDate); } recordObject.remove(DbSingleton.TicketSchema.COLUMN_LAST_MODIFIED); recordObject.put(DbSingleton.TicketSchema.COLUMN_LAST_MODIFIED, mDateFormat.format(new java.util.Date())); recordObject.remove("TMSRowGUID"); //recordObject.remove(DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER); //recordObject.put(DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER, getNextTicketNumber()); //get column names JsonParser parser = new JsonParser(); JsonObject recordGson = parser.parse(recordObject.toString()).getAsJsonObject(); Set<Map.Entry<String, JsonElement>> entrySet = recordGson.entrySet(); Integer ticketID = null; //get values { Iterator<Map.Entry<String, JsonElement>> iterator = entrySet.iterator(); while (iterator.hasNext()) { Map.Entry<String, JsonElement> entry = iterator.next(); if (entry.getKey().equals("metadata")) { //do nothing } else { JsonPrimitive value = entry.getValue().getAsJsonPrimitive(); //System.out.println(entry.getKey()+" : "+value.getAsString()); if (value.isString()) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : '"+value.getAsString()+"'"); valuesPortion += entry.getKey() + "="; valuesPortion += "'" + value.getAsString() + "'"; } else if (value.isNumber()) { if (value.getAsString().contains(".")) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Double(value.getAsDouble()).toString())); valuesPortion += entry.getKey() + "="; valuesPortion += new Double(value.getAsDouble()).toString(); } else { //String ticketNumber = new Long(value.getAsLong()).toString(); Long val = new Long(value.getAsLong()); if (entry.getKey().equals(DbSingleton.TicketSchema.COLUMN_TICKET_ID)) { ticketID = val.intValue(); } else { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Long(value.getAsLong()).toString())); valuesPortion += entry.getKey() + "="; valuesPortion += val.toString(); } } } else if (value.isBoolean()) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Boolean(value.getAsBoolean()).toString())); if (value.getAsBoolean()) { valuesPortion += entry.getKey() + "="; valuesPortion += "1"; } else { valuesPortion += entry.getKey() + "="; valuesPortion += "0"; } } } } } //String insertQuery = "INSERT INTO "+DbSingleton.TICKET_DETAIL_TABLE_NAME+"("+columnsPortion+") VALUES ("+valuesPortion+")"; if (ticketID == null) { throw new SQLException("no ticket id found!"); } String updateQuery = "UPDATE " + DbSingleton.TICKET_TABLE_NAME + " SET " + valuesPortion + " WHERE " + DbSingleton.TicketSchema.COLUMN_TICKET_ID + "=" + ticketID; //String identQuery = "SELECT IDENT_CURRENT ('"+DbSingleton.TICKET_DETAIL_TABLE_NAME+"') AS TicketDetailID"; executeQuery(updateQuery); }
From source file:ProcessRequest.java
public void updateTicketDetail(Integer ticketID, JSONObject recordObject) throws SQLException, JSONException { //check for ticket detail existence String valuesPortion = ""; recordObject.remove(DbSingleton.TicketDetailSchema.COLUMN_LAST_MODIFIED); recordObject.put(DbSingleton.TicketDetailSchema.COLUMN_LAST_MODIFIED, mDateFormat.format(new java.util.Date())); recordObject.remove("TMSRowGUID"); String grossDate = null;//from ww w . j a v a2 s . co m try { grossDate = mDateFormat.format( new java.util.Date(recordObject.getLong(DbSingleton.TicketDetailSchema.COLUMN_GROSS_LBS_DT))); } catch (JSONException jsone) { grossDate = recordObject.getString(DbSingleton.TicketDetailSchema.COLUMN_GROSS_LBS_DT); } finally { recordObject.put(DbSingleton.TicketDetailSchema.COLUMN_GROSS_LBS_DT, grossDate); } String grossALTDate = null; try { grossALTDate = mDateFormat.format(new java.util.Date( recordObject.getLong(DbSingleton.TicketDetailSchema.COLUMN_ALT_GROSS_LBS_DT))); } catch (JSONException jsone) { grossALTDate = recordObject.getString(DbSingleton.TicketDetailSchema.COLUMN_ALT_GROSS_LBS_DT); } finally { recordObject.put(DbSingleton.TicketDetailSchema.COLUMN_ALT_GROSS_LBS_DT, grossALTDate); } String tareDate = null; try { tareDate = mDateFormat.format( new java.util.Date(recordObject.getLong(DbSingleton.TicketDetailSchema.COLUMN_TARE_LBS_DT))); } catch (JSONException jsone) { tareDate = recordObject.getString(DbSingleton.TicketDetailSchema.COLUMN_TARE_LBS_DT); } finally { recordObject.put(DbSingleton.TicketDetailSchema.COLUMN_TARE_LBS_DT, tareDate); } String tareALTDate = null; try { tareALTDate = mDateFormat.format(new java.util.Date( recordObject.getLong(DbSingleton.TicketDetailSchema.COLUMN_ALT_TARE_LBS_DT))); } catch (JSONException jsone) { tareALTDate = recordObject.getString(DbSingleton.TicketDetailSchema.COLUMN_ALT_TARE_LBS_DT); } finally { recordObject.put(DbSingleton.TicketDetailSchema.COLUMN_ALT_TARE_LBS_DT, tareALTDate); } String deductDate = null; try { deductDate = mDateFormat.format( new java.util.Date(recordObject.getLong(DbSingleton.TicketDetailSchema.COLUMN_DEDUCT_LBS_DT))); } catch (JSONException jsone) { deductDate = recordObject.getString(DbSingleton.TicketDetailSchema.COLUMN_DEDUCT_LBS_DT); } finally { recordObject.put(DbSingleton.TicketDetailSchema.COLUMN_DEDUCT_LBS_DT, deductDate); } String deductALTDate = null; try { deductALTDate = mDateFormat.format(new java.util.Date( recordObject.getLong(DbSingleton.TicketDetailSchema.COLUMN_ALT_DEDUCT_LBS_DT))); } catch (JSONException jsone) { deductALTDate = recordObject.getString(DbSingleton.TicketDetailSchema.COLUMN_ALT_DEDUCT_LBS_DT); } finally { recordObject.put(DbSingleton.TicketDetailSchema.COLUMN_ALT_DEDUCT_LBS_DT, deductALTDate); } //recordObject.remove(DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER); //recordObject.put(DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER, getNextTicketNumber()); //get column names JsonParser parser = new JsonParser(); JsonObject recordGson = parser.parse(recordObject.toString()).getAsJsonObject(); Set<Map.Entry<String, JsonElement>> entrySet = recordGson.entrySet(); Integer ticketDetailID = null; //get values { Iterator<Map.Entry<String, JsonElement>> iterator = entrySet.iterator(); while (iterator.hasNext()) { Map.Entry<String, JsonElement> entry = iterator.next(); if (entry.getKey().equals("metadata")) { //do nothing } else { JsonPrimitive value = entry.getValue().getAsJsonPrimitive(); //System.out.println(entry.getKey()+" : "+value.getAsString()); if (value.isString()) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : '"+value.getAsString()+"'"); valuesPortion += entry.getKey() + "="; valuesPortion += "'" + value.getAsString() + "'"; } else if (value.isNumber()) { if (value.getAsString().contains(".")) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Double(value.getAsDouble()).toString())); valuesPortion += entry.getKey() + "="; valuesPortion += new Double(value.getAsDouble()).toString(); } else { Long val = new Long(value.getAsLong()); if (entry.getKey().equals(DbSingleton.TicketDetailSchema.COLUMN_TICKET_DETAIL_ID)) { ticketDetailID = val.intValue(); } else { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Long(value.getAsLong()).toString())); valuesPortion += entry.getKey() + "="; //String ticketNumber = new Long(value.getAsLong()).toString(); valuesPortion += val.toString(); } } } else if (value.isBoolean()) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Boolean(value.getAsBoolean()).toString())); if (value.getAsBoolean()) { valuesPortion += entry.getKey() + "="; valuesPortion += "1"; } else { valuesPortion += entry.getKey() + "="; valuesPortion += "0"; } } } } } //String insertQuery = "INSERT INTO "+DbSingleton.TICKET_DETAIL_TABLE_NAME+"("+columnsPortion+") VALUES ("+valuesPortion+")"; if (ticketDetailID == null) { throw new SQLException("no ticket detail id found!"); } String updateQuery = "UPDATE " + DbSingleton.TICKET_DETAIL_TABLE_NAME + " SET " + valuesPortion + " WHERE " + DbSingleton.TicketDetailSchema.COLUMN_TICKET_DETAIL_ID + "=" + ticketDetailID; //String identQuery = "SELECT IDENT_CURRENT ('"+DbSingleton.TICKET_DETAIL_TABLE_NAME+"') AS TicketDetailID"; executeQuery(updateQuery); }
From source file:ProcessRequest.java
public int insertNewTicketDetail(JSONObject recordObject) throws SQLException, JSONException { String valuesPortion = ""; String columnsPortion = ""; //recordObject.remove(DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER); //recordObject.put(DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER, getNextTicketNumber()); //get column names JsonParser parser = new JsonParser(); JsonObject recordGson = parser.parse(recordObject.toString()).getAsJsonObject(); Set<Map.Entry<String, JsonElement>> entrySet = recordGson.entrySet(); {/* w w w . j ava 2 s .c o m*/ Iterator<Map.Entry<String, JsonElement>> iterator = entrySet.iterator(); while (iterator.hasNext()) { Map.Entry<String, JsonElement> entry = iterator.next(); if (entry.getKey().equals("metadata")) { //do nothing } else { JsonPrimitive value = entry.getValue().getAsJsonPrimitive(); //if(value.isString() && value.getAsString().equals("")) { //don't want this null value/key pair //} else { if (!columnsPortion.equals("")) { columnsPortion += ","; } columnsPortion += entry.getKey(); //System.out.println(entry.getKey()+" : "+value.getAsString()); //} } } } //get values { Iterator<Map.Entry<String, JsonElement>> iterator = entrySet.iterator(); while (iterator.hasNext()) { Map.Entry<String, JsonElement> entry = iterator.next(); if (entry.getKey().equals("metadata")) { //do nothing } else { JsonPrimitive value = entry.getValue().getAsJsonPrimitive(); //System.out.println(entry.getKey()+" : "+value.getAsString()); if (value.isString()) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : '"+value.getAsString()+"'"); valuesPortion += "'" + value.getAsString() + "'"; } else if (value.isNumber()) { if (value.getAsString().contains(".")) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Double(value.getAsDouble()).toString())); valuesPortion += new Double(value.getAsDouble()).toString(); } else { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Long(value.getAsLong()).toString())); String ticketNumber = new Long(value.getAsLong()).toString(); valuesPortion += ticketNumber; } } else if (value.isBoolean()) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Boolean(value.getAsBoolean()).toString())); if (value.getAsBoolean()) valuesPortion += "1"; else valuesPortion += "0"; } } } } String insertQuery = "INSERT INTO " + DbSingleton.TICKET_DETAIL_TABLE_NAME + "(" + columnsPortion + ") VALUES (" + valuesPortion + ")"; String identQuery = "SELECT IDENT_CURRENT ('" + DbSingleton.TICKET_DETAIL_TABLE_NAME + "') AS TicketDetailID"; executeQuery(insertQuery); ResultSet identResultSet = executeQuery(identQuery); identResultSet.first(); //System.out.println(identResultSet.getRow()); int ticketDetailID = identResultSet.getInt(1); //System.out.println(ticketID); return ticketDetailID; }
From source file:ProcessRequest.java
public int insertNewTicket(JSONObject recordObject) throws SQLException, JSONException { String valuesPortion = ""; String columnsPortion = ""; recordObject.remove(DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER); recordObject.put(DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER, getNextTicketNumber()); //get column names JsonParser parser = new JsonParser(); JsonObject recordGson = parser.parse(recordObject.toString()).getAsJsonObject(); Set<Map.Entry<String, JsonElement>> entrySet = recordGson.entrySet(); {/*from w w w . j a v a 2s .co m*/ Iterator<Map.Entry<String, JsonElement>> iterator = entrySet.iterator(); while (iterator.hasNext()) { Map.Entry<String, JsonElement> entry = iterator.next(); if (entry.getKey().equals("metadata") || entry.getKey().equals("TicketID")) { //do nothing } else { JsonPrimitive value = entry.getValue().getAsJsonPrimitive(); //if(value.isString() && value.getAsString().equals("")) { //don't want this null value/key pair //} else { if (!columnsPortion.equals("")) { columnsPortion += ","; } columnsPortion += entry.getKey(); //System.out.println(entry.getKey()+" : "+value.getAsString()); //} } } } //get values { Iterator<Map.Entry<String, JsonElement>> iterator = entrySet.iterator(); while (iterator.hasNext()) { Map.Entry<String, JsonElement> entry = iterator.next(); if (entry.getKey().equals("metadata") || entry.getKey().equals("TicketID")) { //do nothing } else { JsonPrimitive value = entry.getValue().getAsJsonPrimitive(); //System.out.println(entry.getKey()+" : "+value.getAsString()); if (value.isString()) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : '"+value.getAsString()+"'"); valuesPortion += "'" + value.getAsString() + "'"; } else if (value.isNumber()) { if (value.getAsString().contains(".")) { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Double(value.getAsDouble()).toString())); valuesPortion += new Double(value.getAsDouble()).toString(); } else { if (!valuesPortion.equals("")) { valuesPortion += ","; } //System.out.println(entry.getKey()+" : "+(new Long(value.getAsLong()).toString())); String ticketNumber = new Long(value.getAsLong()).toString(); valuesPortion += ticketNumber; } } else if (value.isBoolean()) { if (!valuesPortion.equals("")) { valuesPortion += ","; } if (value.getAsBoolean()) valuesPortion += "1"; else valuesPortion += "0"; } } } } String insertQuery = "INSERT INTO " + DbSingleton.TICKET_TABLE_NAME + "(" + columnsPortion + ") VALUES (" + valuesPortion + ")"; String identQuery = "SELECT IDENT_CURRENT ('" + DbSingleton.TICKET_TABLE_NAME + "') AS TicketID"; executeQuery(insertQuery); ResultSet identResultSet = executeQuery(identQuery); identResultSet.first(); //System.out.println(identResultSet.getRow()); int ticketID = identResultSet.getInt(1); //System.out.println(ticketID); ////////////////////TICKET NUMBER CHECK boolean uniqueTicketNumber = false; while (!uniqueTicketNumber) { String ticketNumberCheckQuery = "SELECT * FROM " + DbSingleton.TICKET_TABLE_NAME + " WHERE " + DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER + "=" + recordObject.getInt(DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER); ResultSet ticketNumberCheckResultSet = executeQuery(ticketNumberCheckQuery); int rowCount = 0; ticketNumberCheckResultSet.last(); rowCount = ticketNumberCheckResultSet.getRow(); ticketNumberCheckResultSet.first(); if (rowCount < 1) throw new SQLException(LOG_TAG + ": wat..."); else if (rowCount > 1) { uniqueTicketNumber = false; } else { uniqueTicketNumber = true; } if (!uniqueTicketNumber) { //update the ticket for the next iteration of this loop, attempting, again, to get a unique ticket number String uniqueTicketNumberQuery = "UPDATE " + DbSingleton.TICKET_TABLE_NAME + " SET " + DbSingleton.TicketSchema.COLUMN_TICKET_NUMBER + "=" + getNextTicketNumber() + " WHERE " + DbSingleton.TicketSchema.COLUMN_TICKET_ID + "=" + ticketID; executeQuery(uniqueTicketNumberQuery); } } //////////////////// return ticketID; }
From source file:adams.data.report.ReportJsonUtils.java
License:Open Source License
/** * Creates a report from the JSON object. * * @param jobj the object to get the data from * @return the report, null if failed to create or find data *///from w w w. j av a2 s.co m public static Report fromJson(JsonObject jobj) { Report result; Field field; JsonPrimitive prim; result = new Report(); for (Entry<String, JsonElement> entry : jobj.entrySet()) { prim = entry.getValue().getAsJsonPrimitive(); if (prim.isBoolean()) { field = new Field(entry.getKey(), DataType.BOOLEAN); result.addField(field); result.setBooleanValue(field.getName(), prim.getAsBoolean()); } else if (prim.isNumber()) { field = new Field(entry.getKey(), DataType.NUMERIC); result.addField(field); result.setNumericValue(field.getName(), prim.getAsNumber().doubleValue()); } else { field = new Field(entry.getKey(), DataType.STRING); result.addField(field); result.setStringValue(field.getName(), prim.getAsString()); } } return result; }
From source file:algorithmi.models.Categories.java
public Categories(String data) { //Transforma a string recebida pelo pedido http para json JsonParser jsonParser = new JsonParser(); JsonObject Categories = (JsonObject) jsonParser.parse(data); //Exibe os dados, em formato json System.out.println(Categories.entrySet()); /**//from w w w .jav a 2s . c o m * * Revalidar TUDO, formatos, campos vazios, TUDO!! * */ validateData(); //Associa os dados ao objecto Question this._id = Categories.get("_id").getAsInt(); //ir buscar o max id da bd + 1 this.description = Categories.get("description").getAsString(); }
From source file:algorithmi.models.CodeLang.java
public CodeLang(String data) { //Transforma a string recebida pelo pedido http para json JsonParser jsonParser = new JsonParser(); JsonObject CodeLang = (JsonObject) jsonParser.parse(data); //Exibe os dados, em formato json System.out.println(CodeLang.entrySet()); /**/*www . j a v a 2 s . co m*/ * * Revalidar TUDO, formatos, campos vazios, TUDO!! * */ validateData(); //Associa os dados ao objecto Question this.questionID = CodeLang.get("questionID").getAsInt(); //ir buscar o max id da bd + 1 this.highLevelLandID = CodeLang.get("highLevelLandID").getAsInt(); this.programCode = CodeLang.get("programCode").getAsString(); }
From source file:algorithmi.models.Course.java
License:Apache License
public Course(String data) { //Transforma a string recebida pelo pedido http para json JsonParser jsonParser = new JsonParser(); JsonObject Course = (JsonObject) jsonParser.parse(data); //Exibe os dados, em formato json System.out.println(Course.entrySet()); /**/*from w w w. j av a2s.c om*/ * * Revalidar TUDO, formatos, campos vazios, TUDO!! * */ validateData(); //Associa os dados ao objecto Course this.codCourse = Course.getAsInt(); //ir buscar o max id da bd + 1 this.name = Course.get("name").getAsString(); this.school = Course.get("school").getAsInt(); }
From source file:algorithmi.models.Details.java
public Details(String data) { //Transforma a string recebida pelo pedido http para json JsonParser jsonParser = new JsonParser(); JsonObject details = (JsonObject) jsonParser.parse(data); //Exibe os dados, em formato json System.out.println(details.entrySet()); //Revalidar TUDO, formatos, campos vazios, TUDO!! validateData();//from ww w . j a va 2s . co m this.matrixTestID = details.get("matrixTestID").getAsInt(); this.categoryID = details.get("categoryID").getAsInt(); this.numberOfQuestions = details.get("numberOfQuestions").getAsInt(); }
From source file:algorithmi.models.HighLevelLangs.java
public HighLevelLangs(String data) { //Transforma a string recebida pelo pedido http para json JsonParser jsonParser = new JsonParser(); JsonObject HighLevelLangs = (JsonObject) jsonParser.parse(data); //Exibe os dados, em formato json System.out.println(HighLevelLangs.entrySet()); /**/* w w w . j av a 2 s . c om*/ * * Revalidar TUDO, formatos, campos vazios, TUDO!! * */ validateData(); //Associa os dados ao objecto Question this._id = HighLevelLangs.get("_id").getAsInt(); //ir buscar o max id da bd + 1 this.description = HighLevelLangs.get("description").getAsString(); }