Package org.unidal.webres.json

Examples of org.unidal.webres.json.JsonObject


    return builder.toString();
  }

  public String parseDomain(String content) throws Exception {
    JsonObject object = new JsonObject(content);
    JsonArray projectArray = object.getJSONArray("projects");

    if (projectArray.length() > 0) {
      JsonObject firstProject = projectArray.getJSONObject(0);
      return firstProject.get("project_name").toString();
    }
    return null;
  }
View Full Code Here


    }
    return null;
  }

  public String parseHostname(String content) throws Exception {
    JsonObject object = new JsonObject(content);
    JsonArray resultArray = object.getJSONArray("result");

    if (resultArray.length() > 0) {
      JsonObject firstResult = resultArray.getJSONObject(0);
      return firstResult.get("hostname").toString();
    }
    return null;
  }
View Full Code Here

    return null;
  }

  private Map<String, String> parseInfos(String content) throws Exception {
    Map<String, String> infosMap = new HashMap<String, String>();
    JsonObject project = new JsonObject(content).getJSONObject("project");

    if (project == null) {
      return infosMap;
    }

    Object owner = project.get("rd_duty");
    Object email = project.get("project_email");
    Object phone = project.get("rd_mobile");
    Object level = project.get("project_level");

    if (email != null) {
      infosMap.put("owner", owner.toString());
    } else {
      infosMap.put("owner", null);
View Full Code Here

    }
    return infosMap;
  }

  private String parseInfo(String content, String jsonName, String attrName) throws Exception {
    JsonObject json = new JsonObject(content).getJSONObject(jsonName);

    if (json != null) {
      Object obj = json.get(attrName);

      if (obj != null) {
        return obj.toString();
      }
    }
View Full Code Here

  private static String PROJECT_API = "http://api.cmdb.dp/api/v0.1/bu/%s/products?page=%s";

  public static void main(String args[]) throws Exception {
    String content = fetchContent(BU_API);

    JsonObject object = new JsonObject(content);
    JsonArray projectArray = object.getJSONArray("bu");
    int length = projectArray.length();

    for (int i = 0; i < length; i++) {
      JsonObject project = projectArray.getJSONObject(i);
      String bu = project.getString("bu_name");

      String nextUrl = String.format(PROJECT_API, bu, String.valueOf(1));
      String detailContent = fetchContent(nextUrl);
      print(bu, detailContent);
View Full Code Here

      System.out.println();
    }
  }

  private static void findNextProjects(String bu, String detailContent) throws Exception, IOException {
    JsonObject jobject = new JsonObject(detailContent);
    int number = jobject.getInt("numfound");
    int index = (int) Math.ceil(number * 1.0 / 25.0);


    for (int j = 2; j <= index; j++) {
      String nextUrl = String.format(PROJECT_API, bu, String.valueOf(j));
View Full Code Here

      print(bu, content);
    }
  }

  private static void print(String bu, String detailContent) throws Exception {
    JsonObject object = new JsonObject(detailContent);
    JsonArray projectArray = object.getJSONArray("products");
    int length = projectArray.length();

    for (int i = 0; i < length; i++) {
      JsonObject project = projectArray.getJSONObject(i);
      String projectName = project.getString("product_name");

      System.out.println(bu + "\t" + projectName);
    }
  }
View Full Code Here

    public String getName() {
      return "Reload-CMDB-Ip-Domain-Info";
    }

    public String parseIp(String content) throws Exception {
      JsonObject object = new JsonObject(content);
      JsonArray array = object.getJSONArray("app");

      if (array.length() > 0) {
        return array.getString(0);
      }
      return null;
View Full Code Here

TOP

Related Classes of org.unidal.webres.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.