List of usage examples for com.google.gson JsonObject get
public JsonElement get(String memberName)
From source file:ai.nitro.bot4j.integration.slack.receive.webhook.impl.SlackEventWebhookImpl.java
License:Open Source License
@Override public String post(final HttpServletRequest req, final HttpServletResponse res) { String result = ""; try {/*w w w . ja va2s . c om*/ final String body = CharStreams.toString(req.getReader()); final JsonParser jsonParser = new JsonParser(); final JsonObject jsonReq = jsonParser.parse(body).getAsJsonObject(); if (!jsonReq.has(TYPE)) { LOG.warn("no type in JSON"); } else { final JsonElement typeJsonElement = jsonReq.get(TYPE); final String type = typeJsonElement.getAsString(); switch (type) { case URL_VERIFICATION: result = handleUrlVerification(jsonReq, res); break; case EVENT_CALLBACK: handleEvent(jsonReq, res); break; default: LOG.info("unknown type {}", type); break; } } } catch (final Exception e) { handleException(e); } 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 www . jav a 2 s.co 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()); /**//from ww w . j a v a 2s. 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 ww .j a va 2 s. c o m * * 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 w w 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()); /**/*www . j a v a 2s . co m*/ * * 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(); }
From source file:algorithmi.models.Institutions.java
public Institutions(String data) { //Transforma a string recebida pelo pedido http para json JsonParser jsonParser = new JsonParser(); JsonObject institutions = (JsonObject) jsonParser.parse(data); //Exibe os dados, em formato json System.out.println(institutions.entrySet()); //Revalidar TUDO, formatos, campos vazios, TUDO!! validateData();//from w ww .ja v a 2 s . c o m //TEM DE IR BUSCAR O ULTIMO ID E ACRESCENTAR UM this._id = 123; this.name = institutions.get("name").getAsString(); this.address = institutions.get("address").getAsString(); }
From source file:algorithmi.Models.Question.java
License:Apache License
public Question(String data) { //Transforma a string recebida pelo pedido http para json JsonParser jsonParser = new JsonParser(); JsonObject Question = (JsonObject) jsonParser.parse(data); //Exibe os dados, em formato json System.out.println(Question.entrySet()); /**/* w w w. ja va 2 s . c o m*/ * * Revalidar TUDO, formatos, campos vazios, TUDO!! * */ validateData(); //Associa os dados ao objecto Question this._id = 123; //ir buscar o max id da bd + 1 this.title = Question.get("titulo").getAsString(); this.category = Question.get("categoria").getAsInt(); this.description = Question.get("descricao").getAsString(); this.image = Question.get("imagem").getAsString(); this.algorithm = Question.get("algoritmo").getAsString(); }
From source file:algorithmi.models.QuestionIO.java
public QuestionIO(String data) { //Transforma a string recebida pelo pedido http para json JsonParser jsonParser = new JsonParser(); JsonObject QuestionIO = (JsonObject) jsonParser.parse(data); //Exibe os dados, em formato json System.out.println(QuestionIO.entrySet()); /**//w w w.j a va 2s. c om * * Revalidar TUDO, formatos, campos vazios, TUDO!! * */ validateData(); //Associa os dados ao objecto Question this._id = 123; //ir buscar o max id da bd + 1 this.question = QuestionIO.get("titulo").getAsInt(); this.in = QuestionIO.get("in").getAsString(); this.out = QuestionIO.get("out").getAsString(); }
From source file:algorithmi.models.Schools.java
public Schools(String data) { //Transforma a string recebida pelo pedido http para json JsonParser jsonParser = new JsonParser(); JsonObject schools = (JsonObject) jsonParser.parse(data); //Exibe os dados, em formato json System.out.println(schools.entrySet()); //Revalidar TUDO, formatos, campos vazios, TUDO!! validateData();/*from www . j av a 2 s . c om*/ //TEM DE IR BUSCAR O ULTIMO ID E ACRESCENTAR UM this._id = 123; this.name = schools.get("name").getAsString(); this.institution = schools.get("institution").getAsInt(); }