Example usage for com.google.gson JsonObject getAsInt

List of usage examples for com.google.gson JsonObject getAsInt

Introduction

In this page you can find the example usage for com.google.gson JsonObject getAsInt.

Prototype

public int getAsInt() 

Source Link

Document

convenience method to get this element as a primitive integer value.

Usage

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());
    /**//  w  w w.j ava2  s  . com
     *
     * 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.TypeUser.java

License:Apache License

public TypeUser(String data) {

    //Transforma a string recebida pelo pedido http para json
    JsonParser jsonParser = new JsonParser();
    JsonObject UserType = (JsonObject) jsonParser.parse(data);

    //Exibe os dados, em formato json
    System.out.println(UserType.entrySet());
    /**/*w  ww  .  j a  va 2 s.c  o m*/
     *
     * Revalidar TUDO, formatos, campos vazios, TUDO!!
     *
     */
    validateData();
    //Associa os dados ao objecto UserType
    this.id_Type = UserType.getAsInt(); //ir buscar o max id da bd + 1 
    this.name = UserType.get("name").getAsString();
    //       
}