Examples of toJsonTree()


Examples of com.google.gson.Gson.toJsonTree()

        req.addProperty("method", methodName);

        JsonArray params = new JsonArray();
        if (args != null) {
            for (Object o : args) {
                params.add(gson.toJsonTree(o));
            }
        }
        req.add("params", params);

        String requestData = req.toString();
View Full Code Here

Examples of com.google.gson.Gson.toJsonTree()

        req.addProperty("method", methodName);

        JsonArray params = new JsonArray();
        if (args != null) {
            for (Object o : args) {
                params.add(gson.toJsonTree(o));
            }
        }
        req.add("params", params);

        String requestData = req.toString();
View Full Code Here

Examples of com.google.gson.Gson.toJsonTree()

   *
   * @return HashMap of JWT content
   */
  public HashMap<String, JsonElement> getContent(){
    Gson gson = GsonHelper.getGson();
    JsonObject obj = gson.toJsonTree(getSelectors()).getAsJsonObject();
   
    HashMap<String, JsonElement> content = new HashMap<String,JsonElement>();
    content.put("origin", new JsonPrimitive(getOrigin()));
    if(getTransaction_id() != null)
      content.put("transaction_id", new JsonPrimitive(getTransaction_id()));
View Full Code Here

Examples of com.google.gson.Gson.toJsonTree()

   *
   * @return HashMap of JWT content
   */
  public HashMap<String, JsonElement> getContent() {
    Gson gson = GsonHelper.getGson();
    JsonObject obj = gson.toJsonTree(getCart()).getAsJsonObject();
   
    HashMap<String, JsonElement> content = new HashMap<String, JsonElement>();
    content.put("origin", new JsonPrimitive(getOrigin()));
    content.put("cart", obj);
    if(getTransaction_id() != null)
View Full Code Here

Examples of com.google.gson.Gson.toJsonTree()

                throw new UnsupportedOperationException("Unhandled json type: " + o.toString());
                // protobuf.value(o.toString());
            }
        } else {
            Gson gson = new Gson();
            JsonElement jsonTree = gson.toJsonTree(o);
            write(jsonTree);
            // protobuf.value(o.toString());
        }

    }
View Full Code Here

Examples of com.google.gson.Gson.toJsonTree()

   * @return execution result
   */
  public <R> R execute(MailChimpMethod<R> method) throws IOException, MailChimpException {
    final Gson gson = MailChimpGsonFactory.createGson();

    JsonElement result = execute(buildUrl(method), gson.toJsonTree(method));
    if(result.isJsonObject()) {
      JsonElement error = result.getAsJsonObject().get("error");   
      if(error != null) {
        JsonElement code = result.getAsJsonObject().get("code");
        throw new MailChimpException(code.getAsInt(), error.getAsString());
View Full Code Here

Examples of com.google.gson.Gson.toJsonTree()

      ProviderMetadata providerMetadata = ProviderMetadata.builder()
                                                          .id("test-provider").defaultProperties(props)
                                                          .name("My test provider").build();

      Gson gson = new GsonBuilder().create();
      JsonElement json = gson.toJsonTree(providerMetadata);
      assertNotNull(json);
      assertEquals("test-provider", json.getAsJsonObject().get("id").getAsString());
      assertEquals("value1", json.getAsJsonObject().getAsJsonObject("defaultProperties").get("key1").getAsString());
      assertEquals("value2", json.getAsJsonObject().getAsJsonObject("defaultProperties").get("key2").getAsString());
      assertEquals("value3", json.getAsJsonObject().getAsJsonObject("defaultProperties").get("key3").getAsString());
View Full Code Here

Examples of com.google.gson.Gson.toJsonTree()

   @Test
   void testToJson() {
      Location location = Location.builder().id("region-1a").scope("ZONE").parentId("region-1").iso3166Codes(ImmutableSet.of("IE")).build();
      Gson gson = new GsonBuilder().create();
      JsonElement json = gson.toJsonTree(location);
      assertNotNull(json);
      assertEquals("region-1a", json.getAsJsonObject().get("id").getAsString());
      assertEquals("ZONE", json.getAsJsonObject().get("scope").getAsString());
      assertEquals("region-1", json.getAsJsonObject().get("parentId").getAsString());
      assertEquals("IE", json.getAsJsonObject().get("iso3166Codes").getAsJsonArray().get(0).getAsString());
View Full Code Here

Examples of com.google.gson.Gson.toJsonTree()

   @Test
   void testToJson() {
      Context context = Context.builder().name("my-context").identity("me").providerId("test-provider").build();
      Gson gson = new GsonBuilder().create();
      JsonElement json = gson.toJsonTree(context);
      assertNotNull(json);
      assertEquals("my-context", json.getAsJsonObject().get("name").getAsString());
      assertEquals("me", json.getAsJsonObject().get("identity").getAsString());
      assertEquals("test-provider", json.getAsJsonObject().get("providerId").getAsString());
   }
View Full Code Here

Examples of com.google.gson.Gson.toJsonTree()

                                           .credentialName("credential")
                                           .documentation("http://somehost.org/doc")
                                           .defaultProperties(props).build();

      Gson gson = new GsonBuilder().create();
      JsonElement json = gson.toJsonTree(apiMetadata);
      assertNotNull(json);
      assertEquals("test-api", json.getAsJsonObject().get("id").getAsString());
      assertEquals("value1", json.getAsJsonObject().getAsJsonObject("defaultProperties").get("key1").getAsString());
      assertEquals("value2", json.getAsJsonObject().getAsJsonObject("defaultProperties").get("key2").getAsString());
      assertEquals("value3", json.getAsJsonObject().getAsJsonObject("defaultProperties").get("key3").getAsString());
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.