Package org.codehaus.jackson

Examples of org.codehaus.jackson.JsonParseException


    JsonNode rootNode = parseLocationField(locationField);
    JsonNode pathNode = rootNode.path(path);
    Set<String> url = new HashSet<String>();
    if (pathNode.isMissingNode()){
     
      throw new JsonParseException("The Object '" + path + "' could not be found.", null);
     
    } else if (pathNode.isArray()){
     
      ArrayNode urls = (ArrayNode) rootNode.path(path);
      for(JsonNode currentUrl: urls){
        url.add(currentUrl.getTextValue());
      }
     
    } else if (pathNode.isTextual()){
      url.add(pathNode.getTextValue());
    }

    if (url == null || url.isEmpty()){
     
      throw new JsonParseException("The Object '" + path + "' is empty.", null);

    }
    List<String> urlList = new ArrayList<String>();
    urlList.addAll(url);
    return urlList;
View Full Code Here


    }

    private void validateText(JsonParser jsonParser, String input) throws JsonProcessingException {
        Matcher m = textPattern.matcher(input);
        if (!m.matches()) {
            throw new JsonParseException("Unexpected token: " + input, jsonParser.getTokenLocation());
        }
    }
View Full Code Here

        }
    }

    private void validate(JsonParser jsonParser, String input, String expected) throws JsonProcessingException {
        if (!input.equals(expected)) {
            throw new JsonParseException("Unexpected token: " + input, jsonParser.getTokenLocation());
        }
    }
View Full Code Here

  }

  @Deprecated
  public static void ensureObjectClosed( @Nonnull JsonParser parser ) throws JsonParseException {
    if ( parser.getCurrentToken() != JsonToken.END_OBJECT ) {
      throw new JsonParseException( "No consumed everything " + parser.getCurrentToken(), parser.getCurrentLocation() );
    }
  }
View Full Code Here

  }

  @Deprecated
  public static void ensureParserClosed( @Nonnull JsonParser parser ) throws IOException {
    if ( parser.nextToken() != null ) {
      throw new JsonParseException( "No consumed everything " + parser.getCurrentToken(), parser.getCurrentLocation() );
    }

    parser.close();
  }
View Full Code Here

  public static void nextField( @Nonnull JsonParser parser, @Nonnull String fieldName ) throws IOException {
    nextToken( parser, JsonToken.FIELD_NAME );
    String currentName = parser.getCurrentName();

    if ( !fieldName.equals( currentName ) ) {
      throw new JsonParseException( "Invalid field. Expected <" + fieldName + "> but was <" + currentName + ">", parser.getCurrentLocation() );
    }
  }
View Full Code Here

  @Deprecated
  public static void verifyCurrentToken( @Nonnull JsonParser parser, @Nonnull JsonToken expected ) throws JsonParseException {
    JsonToken current = parser.getCurrentToken();
    if ( current != expected ) {
      throw new JsonParseException( "Invalid token. Expected <" + expected + "> but got <" + current + ">", parser.getCurrentLocation() );
    }
  }
View Full Code Here

  public void nextField( @Nonnull String fieldName ) throws IOException {
    nextToken( JsonToken.FIELD_NAME );
    String currentName = parser.getCurrentName();

    if ( !fieldName.equals( currentName ) ) {
      throw new JsonParseException( "Invalid field. Expected <" + fieldName + "> but was <" + currentName + ">", parser.getCurrentLocation() );
    }
  }
View Full Code Here

  }

  public void verifyCurrentToken( @Nonnull JsonToken expected ) throws JsonParseException {
    JsonToken current = parser.getCurrentToken();
    if ( current != expected ) {
      throw new JsonParseException( "Invalid token. Expected <" + expected + "> but got <" + current + ">", parser.getCurrentLocation() );
    }
  }
View Full Code Here

    nextFieldValue( deserializeFrom, PROPERTY_SUB_TYPE );
    String type = deserializeFrom.getText();

    if ( type == null ) {
      throw new JsonParseException( "Attribute" + PROPERTY_SUB_TYPE + " not found. Cannot find strategy.", deserializeFrom.getCurrentLocation() );
    }

    SerializingStrategy<? extends T, JsonGenerator, JsonParser, JsonProcessingException> strategy = serializingStrategySupport.findStrategy( type );
    Version resolvedVersion = serializingStrategySupport.resolveVersion( strategy, formatVersion );
    return strategy.deserialize( deserializeFrom, resolvedVersion );
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.JsonParseException

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.