Package com.google.gson

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


    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

    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

        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

    @Override
    JsonObject toJson() {
        JsonObject root = new JsonObject();

        addCommonFields(root);
        root.add("display", new JsonPrimitive("all"));

        return root;
    }
View Full Code Here

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

        addCommonFields(root);
        root.add("display", new JsonPrimitive("all"));

        return root;
    }
View Full Code Here

      return new MessageWrapper(seqno, type, message);
    }

    public static String serialize(String type,int seqno,  JsonElement message) {
      JsonObject o = new JsonObject();
      o.add("messageType", new JsonPrimitive(type));
      o.add("sequenceNumber", new JsonPrimitive(seqno));
      o.add("message", message);
      return o.toString();
    }
View Full Code Here

      extractJsonObject(T object, JsonElement valueObj, Gson gson, RawStringData raw)
      throws GsonException {
    if (valueObj.isJsonObject()) {
      object.fromGson(valueObj.getAsJsonObject(), gson, raw);
    } else if (valueObj.isJsonPrimitive()) {
      JsonPrimitive primitive = valueObj.getAsJsonPrimitive();
      String s = null;
      if (raw == null || !primitive.isString()) {
        throw new GsonException("Decoding " + valueObj + " as object " + object.getClass() +
            " with no RawStringData given");
      }
      s = raw.getString(valueObj.getAsString());
      GsonUtil.parseJson(object, gson, s, raw);
View Full Code Here

  /**
   * Faithfully serializes a 64-bit long value as a two-number array.
   */
  public static JsonArray toJson(long value) {
    JsonArray arr = new JsonArray();
    arr.add(new JsonPrimitive(JsonLongHelper.getLowWord(value)));
    arr.add(new JsonPrimitive(JsonLongHelper.getHighWord(value)));
    return arr;
  }
View Full Code Here

    if (src.isAttachment()) {
      Attachment attachment = (Attachment) src;
      if (attachment.hasData()) {
        byte[] encodedData = Base64.encodeBase64(attachment.getData());
        try {
          properties.add(Attachment.DATA, new JsonPrimitive(
            new String(encodedData, "UTF-8")));
        } catch (UnsupportedEncodingException e) {
          // this shouldn't happen, so let it slide.
        }
      }
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.