Examples of fromJson()


Examples of com.google.gson.Gson.fromJson()

      e.printStackTrace();
    }

    // Get metadata for the Module
    List<JsonElement> requestElements = new ArrayList<JsonElement>();
    JsonObject moduleJsonObject = gson.fromJson(output, JsonObject.class);

    JsonElement moduleNameElement = moduleJsonObject.get("moduleName");
    JsonElement moduleDescriptionElement = moduleJsonObject.get("moduleDescription");
    JsonElement moduleVersionElement = moduleJsonObject.get("moduleDescription");
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    private BatchSpec load(File file) throws IOException {
        Gson gson = new Gson();
        InputStream in = new FileInputStream(file);
        try {
            Reader reader = new InputStreamReader(in, Constants.ENCODING);
            BatchSpec result = gson.fromJson(reader, BatchSpec.class);
            reader.close();
            return result;
        } finally {
            in.close();
        }
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

            final Gson gson = new Gson();
            final String postData = gson.toJson(data);
            post.setRequestEntity(new StringRequestEntity(postData, "application/json", "UTF-8"));
            final int status = client.executeMethod(post);
            if (status != 200) throw new RuntimeException("Return Status Code "+post.getStatusCode()+" "+post.getStatusLine());
            return gson.fromJson(post.getResponseBodyAsString(), resultType);
        } catch (Exception e) {
            throw new RuntimeException("Error executing request to "+url+" with "+data+":" + e.getMessage());
        }
    }
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    }

    public static <T> T decode(Context context, Scriptable scope, Object value, Class<T> type) {
        Object json = NativeJSON.stringify(context, scope, value, null, null);
        Gson gson = new Gson();
        return gson.fromJson((String) json, type);
    }

    public static <T> T decode(Context context, Scriptable scope, Object value, TypeToken<T> type) {
        Object json = NativeJSON.stringify(context, scope, value, null, null);
        Gson gson = new Gson();
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    }

    public static <T> T decode(Context context, Scriptable scope, Object value, TypeToken<T> type) {
        Object json = NativeJSON.stringify(context, scope, value, null, null);
        Gson gson = new Gson();
        return gson.fromJson((String) json, type.getType());
    }

    public static <T> Predicate<T> getPredicate(final Context context, final Scriptable thisObj, final Function predicate) {
        return new JavaScriptPredicate<T>(context, thisObj, predicate);
    }
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

            //String[] column = gson.fromJson(test, Object[][].class);
          //  Object[][] column = new Gson().fromJson(jsonEjemplo, Object[][].class);
            Gson gson = new Gson();
                  
                   
                    List<Category> table = gson.fromJson(jsonEjemplo, new TypeToken<List<Category>>(){}.getType());
              
                    for (Category tab : table) {
                        System.out.println("Away Team:  " + tab.getDescription());
                        System.out.println("Away Team:  " + tab.getResult().getfNum());
                    }
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

            //String[] column = gson.fromJson(test, Object[][].class);
          //  Object[][] column = new Gson().fromJson(jsonEjemplo, Object[][].class);
            Gson gson = new Gson();
                   
                   
                    List<Category> table = gson.fromJson(jsonEjemplo, new TypeToken<List<Category>>(){}.getType());
                String salida;
                    for (Category tab : table) {
                      System.out.println("#########");
                      System.out.println("ID:  " + tab.getId());
                      System.out.println("Subtitle:  " + tab.getSubtitle());
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

  protected void execute(HttpServletRequest req, HttpServletResponse resp) {

    Compra compra = new Compra();

    Gson gson = new Gson();
    List<Integer> ids =  gson.fromJson(req.getParameter("produtos"), new TypeToken<List<Integer>>(){}.getType());

    for (Integer id : ids) {
      Produto p = jdo.findById(Produto.class, id);

      compra.setTotal(compra.getTotal().add(p.getPreco()));
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    this.itensJSON = new Text(gson.toJson(this.itens));
  }

  public void loadJSON() {
    Gson gson = new Gson();
    this.itens = gson.fromJson(this.itensJSON.getValue(), new TypeToken<List<ItemCompra>>(){}.getType());
  }


}
View Full Code Here

Examples of com.google.gson.Gson.fromJson()

    try {
      cl = ccl.loadClass(klass);
    } catch (ClassNotFoundException e) {
      log.warn("Error while loading class", e);
    }
    return (Vector) gson.fromJson(vector, cl);
  }

}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.