Package org.json.simple

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


        result.put("code", code);
        result.put("objectId", objectId == null ? "" : objectId);
        result.put("exception", ex == null ? "" : ex);
        result.put("message", message == null ? "" : message);

        return result.toJSONString();
    }

    /**
     * Writes JSON to the servlet response and adds a callback wrapper if
     * requested.
 
View Full Code Here


        jsonProperty("success", true),
        jsonProperty("body", jsonObject(jsonProperty("script", scriptObject))),
        jsonProperty("refs", constructScriptRefsJson())
        );

    sendEvent(createMessage(afterCompileObject.toJSONString()));
  }

  private Message createMessage(String content) {
    return new Message(Collections.<String, String>emptyMap(), content);
  }
View Full Code Here

        JSONObject obj = new JSONObject();
        for (String key : doc.keySet()) {
            Object value = doc.get(key);
            obj.put(key, value);
        }
        return obj.toJSONString();
    }

    private <T extends Document> T fromString(Collection<T> collection, String data) throws ParseException {
        T doc = collection.newDocument(this);
        Map<String, Object> obj = (Map<String, Object>) new JSONParser().parse(data);
View Full Code Here

        assertNull(arr.get(0));
        assertEquals(arr.get(1),"/tmp");
        assertEquals(arr.get(2),10);
        assertEquals(arr.get(3),42.0);
        assertEquals(arr.get(4),false);
        String json = res.toJSONString();
        assertNotNull(json);
        JSONObject reparsed = (JSONObject) new JSONParser().parse(json);
        assertNotNull(reparsed);
        assertEquals(((List) reparsed.get("second")).get(1),"/tmp");
    }
View Full Code Here

    for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
      payload.put(parameter.getKey(), parameter.getValue());
    }

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

        result.put("code", code);
        result.put("objectId", objectId == null ? "" : objectId);
        result.put("exception", ex == null ? "" : ex);
        result.put("message", message == null ? "" : message);

        return result.toJSONString();
    }

    /**
     * Writes JSON to the servlet response and adds a callback wrapper if
     * requested.
 
View Full Code Here

        assertNotNull("expecing deletionInfo to be present", serializedDeletionInfo);

        assertEquals(
                "unexpected serialization format for topLevelDeletion",
                "{\"markedForDeleteAt\":0,\"localDeletionTime\":0}",
                serializedDeletionInfo.toJSONString());

        // check the colums are what we put in
        JSONArray cols = (JSONArray) row.get("columns");
        assertNotNull("expecing columns to be present", cols);
        assertEquals("expecting two columns", 2, cols.size());
View Full Code Here

            sb.append(hadoopId);
            // Hadoop Counters for pig created MR job
            pigStatsGroup.put(hadoopId, toJSONFromJobStats(jobStats));
        }
        pigStatsGroup.put("JOB_GRAPH", sb.toString());
        return pigStatsGroup.toJSONString();
    }

    // MR job related counters
    @SuppressWarnings("unchecked")
    private static JSONObject toJSONFromJobStats(JobStats jobStats) {
View Full Code Here

        JSONObject obj = new JSONObject();
        for (String key : doc.keySet()) {
            Object value = doc.get(key);
            obj.put(key, value);
        }
        return obj.toJSONString();
    }

    private <T extends Document> T fromString(Collection<T> collection, String data) throws ParseException {
        T doc = collection.newDocument(this);
        Map<String, Object> obj = (Map<String, Object>) new JSONParser().parse(data);
View Full Code Here

  public void writeTo(ResultSet resultSet, Class<?> type, Type genericType,
      Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,
      Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {

    JSONObject json = toJsonSource(resultSet);
    entityStream.write(json.toJSONString().getBytes("UTF-8"));
  }

  /**
   * Helper: transforms a {@link ResultSet} or a {@link Boolean} to a
   * json object.
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.