Examples of GsonBuilder


Examples of com.google.gson.GsonBuilder

        }
        return scanner;
    }

    public static SpoutState fromString(String serialized) {
        GsonBuilder gson = new GsonBuilder();
        gson.registerTypeAdapter(SpoutState.class, new SpoutStateAdapter());
        return gson.create().fromJson(serialized, SpoutState.class);
    }
View Full Code Here

Examples of com.google.gson.GsonBuilder

      html_file.close();
  }

  HTMLStatusExtractor hse = new HTMLStatusExtractor();
  JsonObject json = hse.extractTweet(buf.toString());
  Gson gson = new GsonBuilder().setPrettyPrinting().create();
  System.out.println(gson.toJson(json));
    }
View Full Code Here

Examples of com.google.gson.GsonBuilder

    outputObjects.add("queries", outputJsonArray);
  }


  public String toString() {
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    String json = gson.toJson(outputObjects);
    return json;
  }
View Full Code Here

Examples of com.google.gson.GsonBuilder

                } else if (s.equals("${game_assets}") || s.equals("${assets_root}")) {
                    arguments.add(assetDir.getAbsolutePath());
                } else if (s.equals("${assets_index_name}")) {
                    arguments.add(assetIndex == null ? "legacy" : assetIndex);
                } else if (s.equals("${user_properties}")) {
                    arguments.add(new GsonBuilder().registerTypeAdapter(PropertyMap.class, new OldPropertyMapSerializer()).create().toJson(authentication.getUserProperties()));
                } else if (s.equals("${user_properties_map}")) {
                    arguments.add(new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(authentication.getUserProperties()));
                } else if (isLegacy) {
                    arguments.add(parseLegacyArgs(s));
                } else {
                    arguments.add(s);
                }
View Full Code Here

Examples of com.google.gson.GsonBuilder

    }

    private static String encode (Map<String, Object> m) {
        try {
            Gson gson;
            final GsonBuilder builder = new GsonBuilder();
            builder.registerTypeAdapterFactory(new EnumAdaptorFactory());
            builder.registerTypeAdapter(Date.class, new DateAdapter());
            builder.registerTypeAdapter(File.class, new FileAdapter());
            builder.enableComplexMapKeySerialization();
            builder.setPrettyPrinting();
            gson = builder.create();
            return gson.toJson(m);
        } catch (Exception e) {
            Logger.logError("Error encoding Authlib JSON", e);
            return null;
        }
View Full Code Here

Examples of com.google.gson.GsonBuilder

    }

    void process(Class<? extends BatchDescription> description) throws IOException {
        LOG.info("Extracting metadata: {}", description.getName());
        BatchSpec spec = toSpec(description);
        Gson gson = new GsonBuilder()
            .setPrettyPrinting()
            .create();

        OutputStream output = getEnvironment().openResource(Constants.PATH);
        try {
View Full Code Here

Examples of com.google.gson.GsonBuilder

    }

    private static void explainBatch(BatchScript script) throws IOException {
        assert script != null;
        JsonObject batch = analyzeBatch(script);
        Gson gson = new GsonBuilder()
            .disableHtmlEscaping()
            .setPrettyPrinting()
            .create();
        Writer writer = new PrintWriter(new OutputStreamWriter(System.out, Charset.defaultCharset()));
        gson.toJson(batch, writer);
View Full Code Here

Examples of com.google.gson.GsonBuilder

        }
        return result;
    }

    private String toJson(Object result) {
        return new GsonBuilder().serializeNulls().create().toJson(result);
    }
View Full Code Here

Examples of com.google.gson.GsonBuilder

    private String toJson(Object result) {
        return new GsonBuilder().serializeNulls().create().toJson(result);
    }
    private Map fromJson(String input) {
        return new GsonBuilder().serializeNulls().create().fromJson(input, Map.class);
    }
View Full Code Here

Examples of com.google.gson.GsonBuilder

  private static final Logger log = LoggerFactory.getLogger(JsonVectorAdapter.class);
  public static final String VECTOR = "vector";

  public JsonElement serialize(Vector src, Type typeOfSrc,
                               JsonSerializationContext context) {
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    JsonObject obj = new JsonObject();
    obj.add(JsonMatrixAdapter.CLASS, new JsonPrimitive(src.getClass().getName()));
    obj.add(VECTOR, new JsonPrimitive(gson.toJson(src)));
    return obj;
  }
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.