Package com.restartle.json

Examples of com.restartle.json.JsonObject


    IOUtil.writeStringToFile(sb.toString(), file);
  }

  @SuppressWarnings("unused")
  private void analyze(String url) {
    JsonObject rawJson = fetchAndParse(url);
   
    Dumper dumper = Dumper.stdout();
    analyze(dumper, rawJson);
  }
View Full Code Here


    for (Map.Entry<String, Object> entry : json.entrySet()) {
      String key = entry.getKey();
      Object value = entry.getValue();
     
      if (value instanceof JsonObject) {
        JsonObject obj = (JsonObject) value;
        if (obj.prettyprint().length() <= 100) {
          dumper.line("%: %", key, ((JsonObject) value).prettyprint());
        } else {
          dumper.line("%", key);
          dumper.indent();
          analyze(dumper, obj);
View Full Code Here

   *     expect any fields to be defined here. unless isReservedInstance is true, in which case reservationType
   *     should be populated but we will prefix "1 year " or "3 year ".
   * @param optionsArray Array in which we accumulate the options.
   */
  private void accumulateEC2Options(String url, boolean isReservedInstance, Tuple baseTuple, List<Tuple> optionsArray) {
    JsonObject rawJson = fetchAndParse(url);
    JsonObject config = rawJson.getJson("config");
   
    for (JsonObject ec2Region : config.getArray("regions").getObjectIterable()) {
      String ec2RegionName = ec2Region.getString("region");
      for (JsonObject instanceType : ec2Region.getArray("instanceTypes").getObjectIterable()) {
        String instanceTypeName = instanceType.getString("type");
       
        for (JsonObject size : instanceType.getArray("sizes").getObjectIterable()) {
          String sizeName = size.getString("size");
         
          if (isReservedInstance) {
            JsonObject map = columnsToMap(size.getArray("valueColumns"));
            double upfront = getPrice(map, "yrTerm1"), hourly = getPrice(map, "yrTerm1Hourly");
            if (upfront >= 0 && hourly >= 0) {
              Tuple tuple = new Tuple(baseTuple);
              parseAmazonRegion(ec2RegionName, tuple);
              parseAmazonInstanceType(instanceTypeName, sizeName, tuple);
View Full Code Here

  private JsonObject fetchAndParse(String url) {
    String rawData = new HttpClient()
        .setUrl(url)
        .setTimeoutMs(20 * 1000)
        .executeGet();
    JsonObject rawJson = JsonUtil.parseJson(rawData);
    return rawJson;
  }
View Full Code Here

 
  /**
   * Given one of Amazon's "columns" arrays, return the same value as a map, indexed by the column's "name" attribute.
   */
  private JsonObject columnsToMap(JsonArray columns) {
    JsonObject result = new JsonObject();
    for (JsonObject column : columns.getObjectIterable())
      result.put(column.getString("name"), column);
   
    return result;
  }
View Full Code Here

      flashMB = src.flashMB;
      networkMbps = src.flashMB;
    }
   
    public JsonObject toJson() {
      return new JsonObject()
          .set("provider", provider.toString())
          .set("region", region.toString())
          .set("location", location)
          .set("reservationType", reservationType)
          .set("serverType", serverType)
View Full Code Here

TOP

Related Classes of com.restartle.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.