Package org.json.simple

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


    JSONObject jsonObject = (JSONObject) json;
    JSONArray features = (JSONArray) jsonObject.get("features");
    JSONObject feature = (JSONObject) features.get(0);
    JSONObject geometry = (JSONObject) feature.get("geometry");
    GeometryJSON g = new GeometryJSON(0);
    Geometry m = g.read(geometry.toJSONString());
    Envelope envelope = new Envelope(0, 1, 0, 1);
    Geometry orig = JTS.toGeometry(envelope);
    Geometry m2 = geoservice.transform(orig, "EPSG:4326", "EPSG:900913");
    // equality check on buffer, JTS equals does not do the trick !
    Assert.assertTrue(m.buffer(0.01).contains(m2));
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

    Object obj = parser.parse(new FileReader(TestData.TEST_ROOT_CERTS));
    JSONObject response = (JSONObject) obj;
   
    HttpInvoker mockInvoker = mock(HttpInvoker.class);
    when(mockInvoker.makeGetRequest(eq("http://ctlog/get-roots"))).thenReturn(
        response.toJSONString());

    HttpLogClient client = new HttpLogClient("http://ctlog/", mockInvoker);
    List<Certificate> rootCerts = client.getLogRoots();

    Assert.assertNotNull(rootCerts);
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

        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

          eventCount = (Long) eventsGrouped.get(event.getChapterId().toString());
        }
        eventsGrouped.put(""+event.getChapterId(), ++eventCount);
      }

      options = options.param(KEY, eventsGrouped.toJSONString());
    }
  }

  private void groupEventsByCountry(HttpServletRequest request,
      List<Event> events, TaskOptions options) {
View Full Code Here

          eventCount = (Long) eventsGrouped.get(event.getChapterId().toString());
        }
        eventsGrouped.put(""+event.getChapterId(), ++eventCount);
      }

      options = options.param(KEY, eventsGrouped.toJSONString());
    }
  }

  private void groupEventsByTopic(HttpServletRequest request,
      List<Event> events, TaskOptions options) {
View Full Code Here

            eventsGrouped.put(topicEntry.getKey(), ++count);
          }
        }
      }

      options = options.param(KEY, eventsGrouped.toJSONString());
    }
  }
}
View Full Code Here

    } else {
      for (Chapter chapter : chapters) {
        countries.put(chapter.getCountry(), Boolean.TRUE);
      }

      options = options.param(KEY, countries.toJSONString());
    }
  }
}
View Full Code Here

    // Extract all form inputs including sensitive inputs
    JSONObject connectionJson = connectionBean.extract(false);

    String response = super.post(serverUrl + RESOURCE,
                                 connectionJson.toJSONString());

    ValidationBean validationBean = new ValidationBean();
    validationBean.restore((JSONObject) JSONValue.parse(response));

    return validationBean;
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.