Examples of JsonSlurper


Examples of groovy.json.JsonSlurper

     * @throws IOException
     */
    public Object parseJSON( HttpResponse resp ) throws IOException {
        // there is a bug in the JsonSlurper.parse method...
        //String jsonTxt = DefaultGroovyMethods.getText( parseText( resp ) );
        return new JsonSlurper().parse( parseText( resp ) );
    }
View Full Code Here

Examples of groovy.json.JsonSlurper

   * is returned, wait 10 seconds.
   */
  @Override
  protected void doSendLine(String line) {
    ObjectMapper mapper = new ObjectMapper();
    JsonSlurper jsonSlurper = new JsonSlurper();
    @SuppressWarnings("unchecked")
    Map<String, List<Map<String, ?>>> map = (Map<String, List<Map<String, ?>>>) jsonSlurper.parseText(line);
    List<Map<String, ?>> statuses = map.get("statuses");
    for (Map<String, ?> tweet : statuses) {
      StringWriter sw = new StringWriter();
      try {
        mapper.writeValue(sw, tweet);
View Full Code Here

Examples of groovy.json.JsonSlurper

    if (type.equals(TYPE_STRING)) {
      grailsEvents.event(topic, readPacket(stream), EventsPushConstants.FROM_BROWSERS, null, null, null);
    } else if (type.equals(TYPE_JSON)) {
      grailsEvents.event(topic,
          new JsonSlurper().parse(new BufferedReader(new InputStreamReader(stream))),
          EventsPushConstants.FROM_BROWSERS, null, null, null
      );
    } else if (type.equals(TYPE_BINARY)) {
      PipedOutputStream pipeOut = new PipedOutputStream();
      PipedInputStream pipeIn = new PipedInputStream(pipeOut, 4096);
View Full Code Here

Examples of net.sf.json.groovy.JsonSlurper

    private static final String WHILE_1 = "while(1);";

    public static boolean isValidJson(String value) {
        try {
            JSON json = new JsonSlurper().parseText(value);
            return json != null && !(json instanceof JSONNull);
        } catch (Exception e) {
            return false;
        }
    }
View Full Code Here

Examples of net.sf.json.groovy.JsonSlurper

    public static boolean seemsToBeJson(String content) {
        if (!StringUtils.hasContent(content)) {
            return false;
        }
        try {
            new JsonSlurper().parseText(content);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
View Full Code Here

Examples of net.sf.json.groovy.JsonSlurper

    public JsonPathFacade(String targetJson) {
        if (!isValidJson(targetJson)) {
            throw new IllegalArgumentException("Invalid JSON: " + targetJson);
        }
        this.currentJson = targetJson;
        jsonObject = new JsonSlurper().parseText(targetJson);
    }
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.