Package com.google.gson

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


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


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

                } 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

    }

    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

    }

    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

    }

    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

        }
        return result;
    }

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

    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

  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

    return obj;
  }

  public Vector deserialize(JsonElement json, Type typeOfT,
                            JsonDeserializationContext context) throws JsonParseException {
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Vector.class, new JsonVectorAdapter());
    Gson gson = builder.create();
    JsonObject obj = json.getAsJsonObject();
    String klass = obj.get(JsonMatrixAdapter.CLASS).getAsString();
    String vector = obj.get(VECTOR).getAsString();
    ClassLoader ccl = Thread.currentThread().getContextClassLoader();
    Class<?> cl = null;
View Full Code Here

TOP

Related Classes of com.google.gson.GsonBuilder

Copyright © 2018 www.massapicom. 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.