Package org.json.simple

Examples of org.json.simple.JSONObject


    final String customKey = "string";
    final String customValue = "Hello";

    this.builder.addCustomProperty(customKey, customValue);

    final JSONObject payload = (JSONObject) this.parser.parse(this.builder.buildWithDefaultMaximumLength());

    assertEquals(customValue, payload.get(customKey));
  }
View Full Code Here


    assertTrue(payloadString.getBytes(Charset.forName("UTF-8")).length <= maxLength);
  }

  private JSONObject extractApsObjectFromPayloadString(final String payloadString) throws ParseException {
    final JSONObject payload = (JSONObject) this.parser.parse(payloadString);
    return (JSONObject) payload.get("aps");
  }
View Full Code Here

   
    // parse training data into clusters
    Map<String, Clusters> clusterMembership = new HashMap<String, Clusters>();
    JSONParser parser = new JSONParser();
    try {
      JSONObject parseObj = (JSONObject) parser.parse(new FileReader(trainingFile));
      JSONObject topicObj = (JSONObject) parseObj.get("topics");
      Set<String> topics = topicObj.keySet();
      Iterator<String> topicIt = topics.iterator();
      while (topicIt.hasNext()) { // for each topic
        String topic = topicIt.next();
        clusterMembership.put(topic, new Clusters());
        JSONArray clusters = (JSONArray) ((JSONObject) topicObj.get(topic)).get("clusters");
        Iterator<JSONArray> clusterIt = clusters.iterator();
        while (clusterIt.hasNext()) { // for each cluster in the topic
          JSONArray cluster = (JSONArray) clusterIt.next();
          Cluster c = new Cluster();
          Iterator<String> clusterMemberIt = cluster.iterator();
View Full Code Here

    // TODO, assume the url is a file path for now.
    java.nio.file.Path configFile = Paths.get(configFileUrl);
    java.nio.file.Path preferenceFile = Paths.get(preferenceFileUrl);
    try {
      JSONParser parser = new JSONParser();
      JSONObject configJsonObject =
          (JSONObject) parser.parse(this.utils.readFile(configFile));
      JSONObject preferenceJsonObject =
          (JSONObject) parser.parse(this.utils.readFile(preferenceFile));

      String isAllowTracking = mergeBooleanSetting(
          "allow-anonymous-usage-tracking",
          configJsonObject,
View Full Code Here

      .bodyString(body, ContentType.APPLICATION_JSON)
      .execute().returnContent().asString();
    } catch (Throwable t) {
      throw new GistPublishException(ExceptionUtils.getStackTrace(t));
    }
    JSONObject parsed = (JSONObject) JSONValue.parse(response);
    String githubUrl = (String) parsed.get("html_url");
    int slash = githubUrl.lastIndexOf("/");
    if (slash < 0) {
      System.err.println("no slash found in github url: " + githubUrl);
      return githubUrl;
    }
View Full Code Here

    utils.ensureFileHasContent(preferenceFile, defaultPreferenceFile);
    this.preferenceFileUrl = preferenceFile;

    String content = utils.readFile(this.preferenceFileUrl);
   
    JSONObject obj = (JSONObject)JSONValue.parse(content);
    if (obj.get("gist_server") != null)
        this.gist_server = (String)obj.get("gist_server");
    else
        this.gist_server = "https://api.github.com/gists";
       
    if (obj.get("sharing_server") != null)
        this.sharing_server = (String)obj.get("sharing_server");
    else
        this.sharing_server = "http://sharing.beakernotebook.com/gist/anonymous";
   
    final String prefDefaultNotebookUrl = pref.getDefaultNotebookUrl();
    final String mainDefaultNotebookPath = this.dotDir + "/config/default.bkr";
View Full Code Here

   */
  @Override
  @SuppressWarnings("unchecked")
  public JSONObject execute(FileSystem fs) throws IOException {
    boolean ret = fs.setReplication(path, replication);
    JSONObject json = new JSONObject();
    json.put("setReplication", ret);
    return json;
  }
View Full Code Here

   */
  @Override
  @SuppressWarnings("unchecked")
  public JSONObject execute(FileSystem fs) throws IOException {
    Path homeDir = fs.getHomeDirectory();
    JSONObject json = new JSONObject();
    homeDir = FSUtils.convertPathToHoop(homeDir, HoopServer.get().getBaseUrl());
    json.put("homeDir", homeDir.toString());
    return json;
  }
View Full Code Here

   * @param value for the value of the entry.
   * @return the JSON representation of the key-value pair.
   */
  @SuppressWarnings("unchecked")
  public static JSONObject toJSON(String name, Object value) {
    JSONObject json = new JSONObject();
    json.put(name, value);
    return json;
  }
View Full Code Here

        response = Response.ok(json).type(MediaType.APPLICATION_JSON).build();
        break;
      }
      case HOMEDIR: {
        FSHomeDir command = new FSHomeDir();
        JSONObject json = fsExecute(user, doAs.value(), command);
        AUDIT_LOG.info("");
        response = Response.ok(json).type(MediaType.APPLICATION_JSON).build();
        break;
      }
      case INSTRUMENTATION: {
View Full Code Here

TOP

Related Classes of org.json.simple.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.