Package org.json.simple

Examples of org.json.simple.JSONArray.toJSONString()


      request.put("params", requestParams);
      requestArray.add(request);
    }

    try {
      return requestArray.toJSONString().getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
      return null;
    }
  }
View Full Code Here


        // Export to JSON and verify
        File tempJson = File.createTempFile("CFWithDeletionInfo", ".json");
        SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[0]);

        JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
        System.out.println(json.toJSONString());
        assertEquals("unexpected number of rows", 1, json.size());

        JSONObject row = (JSONObject)json.get(0);
        assertEquals("unexpected number of keys", 3, row.keySet().size());
        assertEquals("unexpected row key",asHex("rowA"),row.get("key"));
View Full Code Here

   */
  private List<RestActivity> getListActivitiesFromResponse(HttpResponse response) {
    try {
      JSONObject jsonObject = (JSONObject) JSONValue.parse(getContent(response));
      JSONArray jsonArray =  (JSONArray)jsonObject.get("activities");
      List<RestActivity> activities = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonArray.toJSONString());
      List<RestActivity> copyRestActivities = new ArrayList(activities);
      Collections.copy(copyRestActivities, activities);
      return copyRestActivities;
    } catch (Exception e) {
      throw new ServiceException(ActivityService.class,"invalid response",null);
View Full Code Here

   */
  private List<RestActivity> getListActivitiesFromResponse(HttpResponse response) {
    try {
      JSONObject jsonObject = (JSONObject) JSONValue.parse(getContent(response));
      JSONArray jsonArray =  (JSONArray)jsonObject.get("activities");
      List<RestActivity> activities = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonArray.toJSONString());
      List<RestActivity> copyRestActivities = new ArrayList(activities);
      Collections.copy(copyRestActivities, activities);
      return copyRestActivities;
    } catch (Exception e) {
      throw new ServiceException(ActivityService.class,"invalid response",null);
View Full Code Here

   */
  private List<RestActivity> getListActivitiesFromResponse(HttpResponse response) {
    try {
      JSONObject jsonObject = (JSONObject) JSONValue.parse(getContent(response));
      JSONArray jsonArray =  (JSONArray)jsonObject.get("activities");
      List<RestActivity> activities = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonArray.toJSONString());
      List<RestActivity> copyRestActivities = new ArrayList(activities);
      Collections.copy(copyRestActivities, activities);
      return copyRestActivities;
    } catch (Exception e) {
      throw new ServiceException(ActivityService.class,"invalid response",null);
View Full Code Here

                                      "\"likedByIdentities\":null,\"titleId\":null,\"comments\":null}" +
                           "]}";

    JSONObject jsonObject = (JSONObject) JSONValue.parse(jsonActivity1);
    JSONArray jsonArray =  (JSONArray)jsonObject.get("activities");
    RestActivity model3 = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonArray.toJSONString()).get(0);
    assertEquals(model3.getIdentityId(), "f845f6ed7f000101003ed4d98a09beb3");
  }
}
View Full Code Here

    JSONObject jsonObject = (JSONObject) JSONValue.parse(jsonActivity1);
    JSONArray jsonArray =  (JSONArray)jsonObject.get("likedByIdentities");
    //
    String actual = model3.getFieldAsString("likedByIdentities");

    assertEquals(actual, jsonArray.toJSONString());

    List<RestIdentity> identities = SocialJSONDecodingSupport.JSONArrayObjectParser(RestIdentity.class, actual);
    assertEquals(identities.size(), 1);
  }
View Full Code Here

                                      "\"likedByIdentities\":null,\"titleId\":null,\"comments\":null}" +
                           "]}";

    JSONObject jsonObject = (JSONObject) JSONValue.parse(jsonActivity1);
    JSONArray jsonArray =  (JSONArray)jsonObject.get("activities");
    RestActivity model3 = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonArray.toJSONString()).get(0);
    assertEquals(model3.getIdentityId(), "f845f6ed7f000101003ed4d98a09beb3");
  }

  @Test
  public void shouldJsonActivityStreamArrayParser1() throws Exception {
View Full Code Here

                            + "]"
                            + "}";

    JSONObject jsonObject = (JSONObject) JSONValue.parse(jsonActivity1);
    JSONArray jsonArray =  (JSONArray)jsonObject.get("activities");
    List<RestActivity> activities = SocialJSONDecodingSupport.JSONArrayObjectParser(RestActivity.class, jsonArray.toJSONString());
    assertEquals(activities.size(), 2);

    for(RestActivity e : activities) {
      assertThat("PosterIdentity must not be null.", e.getPosterIdentity(), notNullValue());
      assertThat("ActivityStream must not be null.", e.getActivityStream(), notNullValue());
View Full Code Here

        // Export to JSON and verify
        File tempJson = File.createTempFile("CFWithDeletionInfo", ".json");
        SSTableExport.export(reader, new PrintStream(tempJson.getPath()), new String[0]);

        JSONArray json = (JSONArray)JSONValue.parseWithException(new FileReader(tempJson));
        System.out.println(json.toJSONString());
        assertEquals("unexpected number of rows", 1, json.size());

        JSONObject row = (JSONObject)json.get(0);
        assertEquals("unexpected number of keys", 3, row.keySet().size());
        assertEquals("unexpected row key",asHex("rowA"),row.get("key"));
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.