Package com.google.gson

Examples of com.google.gson.JsonNull


        public JsonElement serialize(Pair<Long, Long> src, java.lang.reflect.Type typeOfSrc, JsonSerializationContext context) {
            JsonArray array = new JsonArray();
            if (src.first() != null) {
                array.add(s_gson.toJsonTree(src.first()));
            } else {
                array.add(new JsonNull());
            }

            if (src.second() != null) {
                array.add(s_gson.toJsonTree(src.second()));
            } else {
                array.add(new JsonNull());
            }

            return array;
        }
View Full Code Here


        }

        @Override
        public JsonElement serialize(List<PortConfig> src, Type typeOfSrc, JsonSerializationContext context) {
            if (src.size() == 0) {
                return new JsonNull();
            }
            JsonArray array = new JsonArray();
            for (PortConfig pc : src) {
                array.add(s_gson.toJsonTree(pc));
            }
View Full Code Here

     * @return JsonObject with key/value(s) pairs or JsonNull if metadata is null.
     */
    @Override
    public JsonElement serialize(Metadata metadata, Type type, JsonSerializationContext context) {
        if (metadata == null){
            return new JsonNull();
        }
        String[] names = getNames(metadata);
        if (names == null) {
            return new JsonNull();
        }

        JsonObject root = new JsonObject();

        for (String n : names) {
View Full Code Here

        public JsonElement serialize(Pair<Long, Long> src, java.lang.reflect.Type typeOfSrc, JsonSerializationContext context) {
            JsonArray array = new JsonArray();
            if (src.first() != null) {
                array.add(s_gson.toJsonTree(src.first()));
            } else {
                array.add(new JsonNull());
            }

            if (src.second() != null) {
                array.add(s_gson.toJsonTree(src.second()));
            } else {
                array.add(new JsonNull());
            }

            return array;
        }
View Full Code Here

        }

        @Override
        public JsonElement serialize(List<PortConfig> src, Type typeOfSrc, JsonSerializationContext context) {
            if (src.size() == 0) {
                return new JsonNull();
            }
            JsonArray array = new JsonArray();
            for (PortConfig pc : src) {
                array.add(s_gson.toJsonTree(pc));
            }
View Full Code Here

      String key = entry.getKey();
      Object value = entry.getValue();
     
      if (value == null) {
        vals.add(key, new JsonNull());
      } else {
        vals.add(key, new JsonPrimitive(value.toString()));
      }
    }
View Full Code Here

  }

  @Override
  public JsonElement serialize(Array<?> array, Type type, JsonSerializationContext ctx) {
    if (array == null) {
      return new JsonNull();
    }
    JsonArray js = new JsonArray();
    for (String i : array) {
      js.add(ctx.serialize(array.$get(i)));
    }
View Full Code Here

  }

  @Override
  public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
    if (src == null) {
      return new JsonNull();
    }
    return new JsonPrimitive(JSDateUtils.toNormalizedString(src));
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  public JsonElement serialize(Map<?, ?> map, Type typeOfSrc, JsonSerializationContext ctx) {
    if (map == null) {
      return new JsonNull();
    }
    JsonObject js = new JsonObject();
    for (Object k : map) {
      js.add(k.toString(), ctx.serialize(((Map) map).$get(k.toString())));
    }
View Full Code Here

        public JsonElement serialize(Pair<Long, Long> src, java.lang.reflect.Type typeOfSrc, JsonSerializationContext context) {
            JsonArray array = new JsonArray();
            if (src.first() != null) {
                array.add(s_gson.toJsonTree(src.first()));
            } else {
                array.add(new JsonNull());
            }

            if (src.second() != null) {
                array.add(s_gson.toJsonTree(src.second()));
            } else {
                array.add(new JsonNull());
            }

            return array;
        }
View Full Code Here

TOP

Related Classes of com.google.gson.JsonNull

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.