Examples of toJsonTree()


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

        else if ("details".equalsIgnoreCase(req.getParameter("type")))
        {
            String i_uuid = req.getParameter("i_uuid");
            Map<String, Object> dto = getDetails(subDTO.getLookupItem(i_uuid),
                    context);
            JsonElement tree = json.toJsonTree(dto);
            JsonObject jo = new JsonObject();
            jo.add("result", tree);
            resp.getWriter().write(jo.toString());
        }
        else if (isMultipart)
View Full Code Here

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

                            valueMap.containsKey("select-collection-file") ? valueMap
                                    .get("select-collection-file") : -1);
                    dto.add(skip);
                }
            }
            JsonElement tree = json.toJsonTree(dto);
            JsonObject jo = new JsonObject();
            jo.add("result", tree);
            resp.setContentType("text/plain");
//            if you works in localhost mode and use IE10 to debug the feature uncomment the follow line
//            resp.setHeader("Access-Control-Allow-Origin","*");
 
View Full Code Here

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

   * @return execution result
   */
  public <R> R execute(MailChimpMethod<R> method) throws IOException, MailChimpException {
    final Gson gson = MailChimpGsonFactory.createGson();

    JsonElement result = execute(buildUrl(method), gson.toJsonTree(method), method.getMetaInfo().version());
    if(result.isJsonObject()) {
      JsonElement error = result.getAsJsonObject().get("error");   
      if(error != null) {
        JsonElement code = result.getAsJsonObject().get("code");
        throw new MailChimpException(code.getAsInt(), error.getAsString());
View Full Code Here

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

     */
    public static Config load(Path fromFile) throws IOException {
        logger.info("Reading config file {}", fromFile);
        try (Reader reader = Files.newBufferedReader(fromFile, TerasologyConstants.CHARSET)) {
            Gson gson = createGson();
            JsonElement baseConfig = gson.toJsonTree(new Config());
            JsonParser parser = new JsonParser();
            JsonElement config = parser.parse(reader);
            if (!config.isJsonObject()) {
                return new Config();
            } else {
View Full Code Here

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

     */
    public void setModuleConfigs(SimpleUri generatorUri, Map<String, Component> configs) {
        Gson gson = createGsonForModules();
        Map<String, JsonElement> map = Maps.newHashMap();
        for (Map.Entry<String, Component> entry : configs.entrySet()) {
            JsonElement json = gson.toJsonTree(entry.getValue());
            map.put(entry.getKey(), json);
        }
        this.moduleConfigs.put(generatorUri, map);
    }

View Full Code Here

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

    try
    {
      List<ProcessBean> processes = getProcessBeans();
      Type processBeanListType = new TypeToken<List<ProcessBean>>() {}.getType();
      JsonElement list = gson.toJsonTree(processes, processBeanListType);
      object.add("processes", list);
      object.addProperty("memoryMessage", getMemoryUsageAsText());
    }
    catch (Throwable t)
    {
View Full Code Here

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

    try
    {
      List<ProcessBean> processes = getProcessBeans();
      Type processBeanListType = new TypeToken<List<ProcessBean>>() {}.getType();
      JsonElement list = gson.toJsonTree(processes, processBeanListType);
      object.add("processes", list);
      object.addProperty("memoryMessage", getMemoryUsageAsText());
    }
    catch (Throwable t)
    {
View Full Code Here

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

    // body: {"type": class, "fq_name": [parent..., name]}
    public String buildFqnJsonString(Class<? extends ApiObjectBase> cls, List<String> name_list) {
        Gson json = new Gson();
        JsonObject js_dict = new JsonObject();
        js_dict.add("type", json.toJsonTree(getTypename(cls)));
        js_dict.add("fq_name", json.toJsonTree(name_list));
        return   js_dict.toString();
     }

     public String getUuid(String data) {
View Full Code Here

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

    // body: {"type": class, "fq_name": [parent..., name]}
    public String buildFqnJsonString(Class<? extends ApiObjectBase> cls, List<String> name_list) {
        Gson json = new Gson();
        JsonObject js_dict = new JsonObject();
        js_dict.add("type", json.toJsonTree(getTypename(cls)));
        js_dict.add("fq_name", json.toJsonTree(name_list));
        return   js_dict.toString();
     }

     public String getUuid(String data) {
        if (data == null) {
View Full Code Here

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

    }
   
    static String serializeObject(String typename, ApiObjectBase obj) {
        Gson json = getSerializer();
        JsonObject js_dict = new JsonObject();
        js_dict.add(typename, json.toJsonTree(obj));
        return js_dict.toString();
    }
}
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.