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("comparator", new JsonPrimitive(this.comparison.toString()));
        root.add("compareTo", new JsonPrimitive(this.comparisonValue));

        return root;
    }
View Full Code Here

      });

      JsonArray participantsJson = new JsonArray();
      for (ParticipantId participant : wavelet.getParticipants()) {
        String participantAddress = participant.toString();
        participantsJson.add(new JsonPrimitive(participantAddress));
      }

      String id =
          JavaWaverefEncoder.encodeToUriPathSegment(WaveRef.of(wavelet.getWaveId(),
              wavelet.getWaveletId(), docName));
View Full Code Here

      if (propertyElement.isJsonObject())
        return propertyElement.getAsJsonObject();
      if (propertyElement.isJsonArray())
        return propertyElement.getAsJsonArray();
      if (propertyElement.isJsonPrimitive()) {
        JsonPrimitive jsonPrim = propertyElement.getAsJsonPrimitive();
        if (jsonPrim.isBoolean())
          return jsonPrim.getAsBoolean();
        if (jsonPrim.isNumber())
          return jsonPrim.getAsNumber();
        if (jsonPrim.isString())
          return jsonPrim.getAsString();
      }
    }

    return null;
  }
View Full Code Here

        JsonArray artifactsFromShop = new JsonArray();
        ArtifactObject[] artifactObjects = targetObject.getArtifactsFromShop();
        if (artifactObjects != null) {
            for (ArtifactObject a : artifactObjects) {
                artifactsFromShop.add(new JsonPrimitive(a.getDefinition()));
            }
        }
        state.add(ARTIFACTS_FROM_SHOP, artifactsFromShop);

        JsonArray artifactsFromDeployment = new JsonArray();
        DeploymentArtifact[] deploymentArtifacts = targetObject.getArtifactsFromDeployment();
        if (deploymentArtifacts != null) {
            for (DeploymentArtifact a : deploymentArtifacts) {
                artifactsFromDeployment.add(new JsonPrimitive(a.getUrl()));
            }
        }
        state.add(ARTIFACTS_FROM_DEPLOYMENT, artifactsFromDeployment);

        state.addProperty(LAST_INSTALL_VERSION, targetObject.getLastInstallVersion());
View Full Code Here

            }

            if (pathElements.length == 2) {
                // TODO this should be the current set of repository objects?!
                JsonArray result = new JsonArray();
                result.add(new JsonPrimitive(Workspace.ARTIFACT));
                result.add(new JsonPrimitive(Workspace.ARTIFACT2FEATURE));
                result.add(new JsonPrimitive(Workspace.FEATURE));
                result.add(new JsonPrimitive(Workspace.FEATURE2DISTRIBUTION));
                result.add(new JsonPrimitive(Workspace.DISTRIBUTION));
                result.add(new JsonPrimitive(Workspace.DISTRIBUTION2TARGET));
                result.add(new JsonPrimitive(Workspace.TARGET));
                resp.getWriter().println(m_gson.toJson(result));
                return;
            }
            else if (pathElements.length == 3) {
                listRepositoryObjects(workspace, pathElements[2], resp);
View Full Code Here

        JsonArray result = new JsonArray();
        for (RepositoryObject ro : objects) {
            String identity = ro.getDefinition();
            if (identity != null) {
                result.add(new JsonPrimitive(urlEncode(identity)));
            }
        }

        resp.getWriter().println(m_gson.toJson(result));
    }
View Full Code Here

public class EncodedStringTypeAdapter implements JsonSerializer<String>{
    public static final Logger s_logger = Logger.getLogger(EncodedStringTypeAdapter.class.getName());

    @Override
    public JsonElement serialize(String src, Type typeOfResponseObj, JsonSerializationContext ctx) {
        return new JsonPrimitive(encodeString(src));

    }
View Full Code Here

   }

   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

      }

      @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.getItems().entrySet()) {
            JsonObject object = new JsonObject();
            object.addProperty("key", entry.getKey());
            object.addProperty("value", entry.getValue());
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.