Package com.google.gson

Examples of com.google.gson.JsonPrimitive


    private static JsonArray toJsonArray(Collection<String> values) {
        assert values != null;
        JsonArray array = new JsonArray();
        for (String value : values) {
            array.add(new JsonPrimitive(value));
        }
        return array;
    }
View Full Code Here


        public JobStatus.Kind deserialize(
                JsonElement json,
                Type type,
                JsonDeserializationContext context) throws JsonParseException {
            if (json.isJsonPrimitive()) {
                JsonPrimitive primitive = (JsonPrimitive) json;
                if (primitive.isString()) {
                    JobStatus.Kind kind = JobStatus.Kind.findFromSymbol(primitive.getAsString());
                    if (kind != null) {
                        return kind;
                    }
                }
            }
View Full Code Here

            return;
        }

        @Override
        public JsonElement serialize(ExecutionPhase src, Type type, JsonSerializationContext context) {
            return new JsonPrimitive(src.getSymbol());
        }
View Full Code Here

     * @param id
     *            id of the entry to add the comment to
     * @return the id of the comment that was added
     */
    public Long addComment(String comment, Long id) {
        String body = "{\"body\":" + new JsonPrimitive(comment).toString() + "}";
        try {
            return doAuthenticatedPost(DailyMileUtil.buildCommentUrl(id), body);
        } catch (Exception e) {
            throw new RuntimeException("Unable to add comment", e);
        }
View Full Code Here

        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

       
        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

      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

      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

      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

                               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

Related Classes of com.google.gson.JsonPrimitive

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.