Package com.google.gson

Examples of com.google.gson.JsonElement


    }

    // Parse incoming operations.
    JsonArray requestsAsJsonArray = null;

    JsonElement json = null;
    try {
      json = jsonParser.parse(jsonString);
    } catch (JsonParseException e) {
      throw new InvalidRequestException("Couldn't deserialize incoming operations: " +
          jsonString, null, e);
    }

    if (json.isJsonArray()) {
      requestsAsJsonArray = json.getAsJsonArray();
    } else {
      requestsAsJsonArray = new JsonArray();
      requestsAsJsonArray.add(json);
    }
View Full Code Here


    String method = firstOperation.get(RequestProperty.METHOD.key()).getAsString();
    if (isRobotNotifyOperationMethod(method)) {
      JsonObject params = firstOperation.get(RequestProperty.PARAMS.key()).getAsJsonObject();
      if (params.has(ParamsProperty.PROTOCOL_VERSION.key())) {
        JsonElement protocolVersionElement = params.get(ParamsProperty.PROTOCOL_VERSION.key());
        if (!protocolVersionElement.isJsonNull()) {
          return ProtocolVersion.fromVersionString(protocolVersionElement.getAsString());
        }
      }
    }
    return defaultProtocolVersion;
  }
View Full Code Here

    {
        resp.setContentType("application/json");
        resp.setStatus(200);

        JsonParser jsonParser = new JsonParser();
        JsonElement contentJson = jsonParser.parse(req.getReader());
        JsonObject jsonObject = contentJson.getAsJsonObject();
        JsonElement headers = jsonObject.get("headers");
        JsonObject response = new JsonObject();
        String signature;

        try
        {
            // If this is not a multipart upload-related request, Fine Uploader will send a policy document
            // as the value of a "policy" property in the request.  In that case, we must base-64 encode
            // the policy document and then sign it. The will include the base-64 encoded policy and the signed policy document.
            if (headers == null)
            {
                String base64Policy = base64EncodePolicy(contentJson);
                signature = sign(base64Policy);

                // Validate the policy document to ensure the client hasn't tampered with it.
                // If it has been tampered with, set this property on the response and set the status to a non-200 value.
//                response.addProperty("invalid", true);

                response.addProperty("policy", base64Policy);
            }

            // If this is a request to sign a multipart upload-related request, we only need to sign the headers,
            // which are passed as the value of a "headers" property from Fine Uploader.  In this case,
            // we only need to return the signed value.
            else
            {
               signature = sign(headers.getAsString());
            }

            response.addProperty("signature", signature);
            resp.getWriter().write(response.toString());
        }
View Full Code Here

      text.setText(value);
    } else if (index == 1) {
      Gson gson = new GsonBuilder().setPrettyPrinting().create();
      JsonParser jp = new JsonParser();
      try {
        JsonElement je = jp.parse(value);
        String prettyJsonString = gson.toJson(je);
        text.setText(prettyJsonString);
      } catch (JsonSyntaxException e) {
        textType.select(currentTextType);
        throw new RuntimeException(RedisClient.i18nFile.getText(I18nFile.JSONEXCEPTION));
View Full Code Here

               return diff.identical();
            }
            case JSON: {              
               JsonParser parser = new JsonParser();
               JsonElement payloadA = parser.parse(Strings2.toString(a.getPayload()));
               JsonElement payloadB = parser.parse(Strings2.toString(b.getPayload()));
               return Objects.equal(payloadA, payloadB);
            }
            default: {
               return Objects.equal(a, b);
            }
View Full Code Here

   */
  private JsonObject parseClaimRequest(String claimRequestString) {
    if (Strings.isNullOrEmpty(claimRequestString)) {
      return null;
    } else {
      JsonElement el = parser.parse(claimRequestString);
      if (el != null && el.isJsonObject()) {
        return el.getAsJsonObject();
      } else {
        return null;
      }
    }
  }
View Full Code Here

    dataService.exportData(writer);
    writer.endObject();
    writer.close();
   
    // parse the output as a JSON object for testing
    JsonElement elem = new JsonParser().parse(stringWriter.toString());
    JsonObject root = elem.getAsJsonObject();
   
    // make sure the root is there
    assertThat(root.has(MITREidDataService.MITREID_CONNECT_1_1), is(true));
   
    JsonObject config = root.get(MITREidDataService.MITREID_CONNECT_1_1).getAsJsonObject();
View Full Code Here

    dataService.exportData(writer);
    writer.endObject();
    writer.close();
   
    // parse the output as a JSON object for testing
    JsonElement elem = new JsonParser().parse(stringWriter.toString());
    JsonObject root = elem.getAsJsonObject();
   
    // make sure the root is there
    assertThat(root.has(MITREidDataService.MITREID_CONNECT_1_1), is(true));
   
    JsonObject config = root.get(MITREidDataService.MITREID_CONNECT_1_1).getAsJsonObject();
View Full Code Here

    dataService.exportData(writer);
    writer.endObject();
    writer.close();
   
    // parse the output as a JSON object for testing
    JsonElement elem = new JsonParser().parse(stringWriter.toString());
    JsonObject root = elem.getAsJsonObject();
   
    // make sure the root is there
    assertThat(root.has(MITREidDataService.MITREID_CONNECT_1_1), is(true));
   
    JsonObject config = root.get(MITREidDataService.MITREID_CONNECT_1_1).getAsJsonObject();
View Full Code Here

    dataService.exportData(writer);
    writer.endObject();
    writer.close();
   
    // parse the output as a JSON object for testing
    JsonElement elem = new JsonParser().parse(stringWriter.toString());
    JsonObject root = elem.getAsJsonObject();

    // make sure the root is there
    assertThat(root.has(MITREidDataService.MITREID_CONNECT_1_1), is(true));
   
    JsonObject config = root.get(MITREidDataService.MITREID_CONNECT_1_1).getAsJsonObject();
View Full Code Here

TOP

Related Classes of com.google.gson.JsonElement

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.