Examples of JsonPrimitive


Examples of com.google.gson.JsonPrimitive

        return Type.fromApiValue(json.getAsString());
    }

    public JsonElement serialize(Type type, java.lang.reflect.Type typeOfT,
            JsonSerializationContext context) {
        return new JsonPrimitive(type.getApiValue());
    }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

       
        return deserializeFormatter.parseDateTime(json.getAsJsonPrimitive().getAsString()).toDate();
    }
   
    public JsonElement serialize(Date date, Type typeOfT, JsonSerializationContext context) {
        return new JsonPrimitive(deserializeFormatter.print(date.getTime()));
    }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

      if (input.getResources() != null && input.getResources().size() != 0) {
         JsonArray uuidsArray = new JsonArray();

         for (TagResource tagResource : input.getResources()) {
            uuidsArray.add(new JsonPrimitive(tagResource.getUuid()));
         }

         jsonTag.add("resources", uuidsArray);
      }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

      expected.add("meta", metaObject);
      expected.add("requirements", new JsonArray());

      JsonArray tagsArray = new JsonArray();
      tagsArray.add(new JsonPrimitive("tag_uuid_1"));
      tagsArray.add(new JsonPrimitive("tag_uuid_2"));
      expected.add("tags", tagsArray);
      expected.addProperty("vnc_password", "tester");

      JsonObject nicJson = new JsonObject();
View Full Code Here

Examples of com.google.gson.JsonPrimitive

      expected.add("meta", metaObject);
      expected.addProperty("name", "TagCreatedWithResource");

      JsonArray resourcesArray = new JsonArray();
      resourcesArray.add(new JsonPrimitive("96537817-f4b6-496b-a861-e74192d3ccb0"));
      resourcesArray.add(new JsonPrimitive("61bcc398-c034-42f1-81c9-f6d7f62c4ea0"));
      resourcesArray.add(new JsonPrimitive("3610d935-514a-4552-acf3-a40dd0a5f961"));
      resourcesArray.add(new JsonPrimitive("185.12.6.183"));

      expected.add("resources", resourcesArray);
   }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

                               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

Examples of com.google.gson.JsonPrimitive

    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(vectorType, new JsonVectorAdapter());
    builder.registerTypeAdapter(matrixType, new JsonMatrixAdapter());
    Gson gson = builder.create();
    JsonObject obj = new JsonObject();
    obj.add(CLASS, new JsonPrimitive(src.getClass().getName()));
    obj.add(MATRIX, new JsonPrimitive(gson.toJson(src)));
    return obj;
  }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

  public JsonElement serialize(DirichletCluster<?> 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("total", new JsonPrimitive(src.getTotalCount()));
    obj.add("modelClass", new JsonPrimitive(src.getModel().getClass().getName()));
    obj.add("modelJson", new JsonPrimitive(gson.toJson(src)));
    return obj;
  }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

  public JsonElement serialize(Model<?> 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("class", new JsonPrimitive(src.getClass().getName()));
    obj.add("model", new JsonPrimitive(gson.toJson(src)));
    return obj;
  }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

    private static class GsonDateSerializer implements JsonSerializer<Date>, JsonDeserializer<Date> {
        private String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS Z";

        @Override
        public JsonElement serialize(Date date, Type typeOfT, JsonSerializationContext context) {
            return new JsonPrimitive(DateUtils.formatDate(date, DATE_FORMAT));
        }
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.