Package javax.json

Examples of javax.json.JsonObject


    @Test
    public void createsAndObtainsTree() throws Exception {
        final String key = System.getProperty("failsafe.github.key");
        Assume.assumeThat(key, Matchers.notNullValue());
        final Trees trees = repo.git().trees();
        final JsonObject json = Json.createObjectBuilder().add(
            "tree",
            Json.createArrayBuilder().add(
                Json.createObjectBuilder()
                    .add("path", "test.txt")
                    .add("mode", "100644")
View Full Code Here


        Assume.assumeThat(key, Matchers.notNullValue());
        final References refs = repo.git().references();
        final String sha = refs.get("refs/heads/master").json()
            .getJsonObject("object").getString("sha");
        final String tag = RandomStringUtils.randomAlphanumeric(Tv.FIVE);
        final JsonObject tagger = Json.createObjectBuilder()
            .add("name", "Scott").add("email", "scott@gmail.com")
            .add("date", "2013-06-17T14:53:35-07:00").build();
        MatcherAssert.assertThat(
            repo.git().tags().create(
                Json.createObjectBuilder()
View Full Code Here

  }


  //
  public static JsonObject buildJSon() {
    JsonObject value = Json.createObjectBuilder()
            .add("id", "1234")
            .add("date", "19/09/2012")
            .add("total_amount", "93.48")
            .add("customer", Json.createObjectBuilder()
                    .add("first_name", "James")
View Full Code Here

            .build();
    return value;
  }

  public static JsonObject buildJSonWithArray() {
    JsonObject itemArrayH2G2 = Json.createObjectBuilder()
            .add("item", "H2G2")
            .add("unit_price", "23.5")
            .add("quantity", "1")
            .build();

    JsonObject itemArrayPotter = Json.createObjectBuilder()
            .add("item", "Harry Potter")
            .add("unit_price", "34.99")
            .add("quantity", "2")
            .build();

    JsonObject value = Json.createObjectBuilder()
            .add("id", "1234")
            .add("date", "19/09/2012")
            .add("total_amount", "93.48")
            .add("customer", Json.createObjectBuilder()
                    .add("first_name", "James")
View Full Code Here

    return value;
  }

  public static JsonObject buildJSonWithArraySeperate() {

    JsonObject customerJames = Json.createObjectBuilder()
            .add("first_name", "James")
            .add("last_name", "Rorrison")
            .add("email", "j.rorri@me.com")
            .add("phoneNumber", "+44 1234 1234")
            .build();

    JsonObject itemArrayH2G2 = Json.createObjectBuilder()
            .add("item", "H2G2")
            .add("unit_price", "23.5")
            .add("quantity", "1")
            .build();

    JsonObject itemArrayPotter = Json.createObjectBuilder()
            .add("item", "Harry Potter")
            .add("unit_price", "34.99")
            .add("quantity", "2")
            .build();

    JsonObject creditCard = Json.createObjectBuilder()
            .add("number", "123412341234")
            .add("expiry_date", "10/13")
            .add("control_number", "234")
            .add("type", "Visa")
            .build();


    JsonObject value = Json.createObjectBuilder()
            .add("id", "1234")
            .add("date", "19/09/2012")
            .add("total_amount", "93.48")
            .add("customer", customerJames)
            .add("content", Json.createArrayBuilder()
View Full Code Here

                if (jsonObject.containsKey(key)) {
                    documentBuilder.add(key, jsonObject.get(key));
                }
            }

            final JsonObject document = documentBuilder.build();
            if (!document.isEmpty()) {
                documents.add(document);
            }
        }

        return documents.build();
View Full Code Here

    for(String error : this.errors) {
        errorBuilder.add(error);
    }
    builder.add("errors", errorBuilder);
   
    JsonObject jsonObject = builder.build();
    return jsonObject.toString();

  }
View Full Code Here

      connection.setRequestProperty("Content-Type",
          "application/x-www-form-urlencoded);charset=UTF-8");

      OutputStream output = connection.getOutputStream();

      JsonObject data = Json.createObjectBuilder().add("file", file)
          .add("temporary", temporary).build();

      output.write(data.toString().getBytes(Charset.forName("UTF-8")));

      InputStream response = connection.getInputStream();
      JsonObject responseData = Json.createReader(response).readObject();

      URI shareLink = new URI(responseData.getString("url"));

      return shareLink;
    } catch (Exception e) {
      throw new Exception("Could not paste the file.", e);
    }
View Full Code Here

   * @return
   * @throws Exception
   */
  public URI submitFile(String fileType, String fileName, String fileContent,
      boolean temporary) throws Exception {
    JsonObject file = Json.createObjectBuilder().add("type", fileType)
        .add("name", fileName).add("content", fileContent).build();

    return submitFile(file, temporary);
  }
View Full Code Here

   */
  @Test
  public void testCase02() throws Exception {
    System.out.println("*** testCase02");
    try (JsonReader reader = Json.createReader(new FileReader("src/test/resources/case02.txt"))) {
      JsonObject obj = reader.readObject();
      navigateTree(obj, null);
      // Close() on reader will be called by try-with-resources statement...
    }
  }
View Full Code Here

TOP

Related Classes of javax.json.JsonObject

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.