Package com.fasterxml.jackson.core

Examples of com.fasterxml.jackson.core.JsonParseException


    JsonToken token = parser.nextToken();
    if (JsonToken.VALUE_NULL == token || JsonToken.END_ARRAY == token) {
      return null;
    }
    if (JsonToken.START_OBJECT != token) {
      throw new JsonParseException("Unexpected token "+token+" - expecting start_object", parser.getCurrentLocation());
    }

    if (desc.inheritInfo == null) {
      return jsonReadObject(parser, path);
    }
   
    // check for the discriminator value to determine the correct sub type
    String discColumn = inheritInfo.getRoot().getDiscriminatorColumn();

    token = parser.nextToken();
    if (token != JsonToken.FIELD_NAME) {
      String msg = "Error reading inheritance discriminator - expected [" + discColumn + "] but no json key?";
      throw new JsonParseException(msg, parser.getCurrentLocation());
    }
   
    String propName = parser.getCurrentName();     
    if (!propName.equalsIgnoreCase(discColumn)) {
      // just try to assume this is the correct bean type in the inheritance
      BeanProperty property = desc.getBeanProperty(propName);
      if (property != null) {
        EntityBean bean = desc.createEntityBean();
        property.jsonRead(parser, bean);
        return jsonReadProperties(parser, bean);
      }
      String msg = "Error reading inheritance discriminator, expected property ["+discColumn+"] but got [" + propName + "] ?";
      throw new JsonParseException(msg, parser.getCurrentLocation());
    }
         
    String discValue = parser.nextTextValue();
   
    // determine the sub type for this particular json object
View Full Code Here


    JsonToken event = parser.nextToken();
    if (JsonToken.VALUE_NULL == event) {
      return;
    }
    if (JsonToken.START_ARRAY != event) {
      throw new JsonParseException("Unexpected token " + event + " - expecting start_array ", parser.getCurrentLocation());
    }

    Object collection = many.createEmpty(false);
    BeanCollectionAdd add = many.getBeanCollectionAdd(collection, null);
    do {
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

  public void ensureObjectClosed() throws JsonParseException {
    JacksonParserWrapper parserWrapper = new JacksonParserWrapper( parser );

    if ( parserWrapper.getCurrentToken() != JsonToken.END_OBJECT ) {
      throw new JsonParseException( "No consumed everything " + parserWrapper.getCurrentToken(), parserWrapper.getCurrentLocation() );
    }
  }
View Full Code Here

  }

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

    parserWrapper.close();
  }
View Full Code Here

      T deserialized = deserializeInternal( parser, version );

      JacksonParserWrapper parserWrapper = new JacksonParserWrapper( parser );
      if ( parserWrapper.nextToken() != null ) {
        throw new JsonParseException( "No consumed everything " + parserWrapper.getCurrentToken(), parserWrapper.getCurrentLocation() );
      }

      parserWrapper.close();
      return deserialized;
    } catch ( InvalidTypeException e ) {
View Full Code Here

    T deserialized = deserialize( parser, version );

    if ( isObjectType() ) {
      if ( parserWrapper.getCurrentToken() != JsonToken.END_OBJECT ) {
        throw new JsonParseException( "No consumed everything " + parserWrapper.getCurrentToken(), parserWrapper.getCurrentLocation() );
      }
    }

    return deserialized;
  }
View Full Code Here

      parserWrapper.nextToken();
      parserWrapper.verifyCurrentToken( JsonToken.FIELD_NAME );
      String currentName = parserWrapper.getCurrentName();

      if ( !propertyName.equals( currentName ) ) {
        throw new JsonParseException( "Invalid field. Expected <" + propertyName + "> but was <" + currentName + ">", parserWrapper.getCurrentLocation() );
      }
      parserWrapper.nextToken();
    }

    List<T> deserialized = new ArrayList<T>();
View Full Code Here

    parserWrapper.nextToken();
    parserWrapper.verifyCurrentToken( JsonToken.FIELD_NAME );
    String currentName = parserWrapper.getCurrentName();

    if ( !propertyName.equals( currentName ) ) {
      throw new JsonParseException( "Invalid field. Expected <" + propertyName + "> but was <" + currentName + ">", parserWrapper.getCurrentLocation() );
    }
    parserWrapper.nextToken();
    return deserialize( type, formatVersion, deserializeFrom );
  }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.core.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.