Examples of JsonPrimitive


Examples of com.google.gson.JsonPrimitive

   }

   private static JsonArray buildArrayOfStrings(Set<String> strings) {
      JsonArray array = new JsonArray();
      for (String string : strings) {
         array.add(new JsonPrimitive(string));
      }
      return array;
   }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

      }

      @Override
      public JsonElement serialize(Metadata src, Type typeOfSrc, JsonSerializationContext context) {
         JsonObject metadataObject = new JsonObject();
         metadataObject.add("kind", new JsonPrimitive("compute#metadata"));
         JsonArray items = new JsonArray();
         for (Map.Entry<String, String> entry : src.entrySet()) {
            JsonObject object = new JsonObject();
            object.addProperty("key", entry.getKey());
            object.addProperty("value", entry.getValue());
View Full Code Here

Examples of com.google.gson.JsonPrimitive

         JsonObject ruleObject = new JsonObject();
         ruleObject.addProperty("IPProtocol", src.getIPProtocol().value());
         if (src.getPorts() != null && !src.getPorts().isEmpty()) {
            JsonArray ports = new JsonArray();
            for (Range<Integer> range : src.getPorts().asRanges()) {
               ports.add(new JsonPrimitive(range.lowerEndpoint() == range.upperEndpoint() ? range.lowerEndpoint() + "" :
                       range.lowerEndpoint() + "-" + range.upperEndpoint()));
            }
            ruleObject.add("ports", ports);
         }
         return ruleObject;
View Full Code Here

Examples of com.google.gson.JsonPrimitive

    JsonElement toJson() {
        JsonObject root = new JsonObject();

        addCommonFields(root);

        root.add("trueLabel", new JsonPrimitive(this.trueDisplayValue));
        root.add("falseLabel", new JsonPrimitive(this.falseDisplayValue));

        return root;
    }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

                StringWriter sw = new StringWriter();
                JSONJAXBContext.getJSONMarshaller(marshaller).marshallToJSON(obj, sw);
                array.add(parser.parse(sw.toString()));
            }
            catch(JAXBException e) {
                array.add(new JsonPrimitive(obj.toString()));
            }
        }
        out.write(new Gson().toJson(array).getBytes());
    }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

        addCommonFields(root);

        JsonObject ranges = new JsonObject();
        // In Splunk 6.0.1.1, data models incorrectly expect strings for these fields
        // instead of numbers. In 6.1, this is fixed and both are accepted.
        if (start != null) ranges.add("start", new JsonPrimitive(start.toString()));
        if (end != null) ranges.add("end", new JsonPrimitive(end.toString()));
        if (step != null) ranges.add("size", new JsonPrimitive(step.toString()));
        if (limit != null) ranges.add("maxNumberOf", new JsonPrimitive(limit.toString()));
        root.add("ranges", ranges);
        root.add("display", new JsonPrimitive("ranges"));

        return root;
    }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

    JsonElement toJson() {
        JsonObject root = new JsonObject();

        addCommonFields(root);

        root.add("comparator", new JsonPrimitive(this.comparison.toString()));
        root.add("compareTo", new JsonPrimitive(this.comparisonValue));

        return root;
    }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

    JsonElement toJson() {
        JsonObject root = new JsonObject();

        addCommonFields(root);

        root.add("attributeName", new JsonPrimitive(this.getAttributeName()));
        root.add("attributeOwner", new JsonPrimitive(Util.join(".", this.getAttributeOwnerLineage())));
        if (sortDirection == SortDirection.ASCENDING) {
            root.add("limitType", new JsonPrimitive("lowest"));
        } else if (sortDirection == SortDirection.DESCENDING) {
            root.add("limitType", new JsonPrimitive("highest"));
        }
        root.add("limitAmount", new JsonPrimitive(this.limit));
        root.add("statsFn", new JsonPrimitive(this.statsFunction.toString()));

        return root;
    }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

    JsonElement toJson() {
        JsonObject root = new JsonObject();

        addCommonFields(root);

        root.add("comparator", new JsonPrimitive(this.comparison.toString()));
        root.add("compareTo", new JsonPrimitive(this.comparisonValue));

        return root;
    }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

        if (e.isJsonNull()) {
            return null;
        } else if (e.isJsonPrimitive()) {

            JsonPrimitive p = e.getAsJsonPrimitive();
            if (p.isString()) {
                return p.getAsString();
            } else if (p.isBoolean()) {
                return p.getAsBoolean();
            } else if (p.isNumber()) {
                return unwrapNumber(p.getAsNumber());
            }
        }
        return o;
    }
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.