Package org.codehaus.jackson

Examples of org.codehaus.jackson.JsonParseException


    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


  }

  @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

        if (domWalker != null) {
            domWalker.startField();
        }
        JsonToken next = parser.nextToken();
        if (next == null) {
            throw new JsonParseException("Expected value, array, or object.", parser.getCurrentLocation());
        }
        if (next.isScalarValue()) {
            String fieldName = parser.getCurrentName();
            handleScalarToken(next, fieldName);
            if (domWalker != null) {
                domWalker.endField();
            }
        } else {
            String fieldName = parser.getCurrentName();
            if (next == JsonToken.START_ARRAY) {
                startArray(fieldName);
            } else if (next == JsonToken.START_OBJECT) {
                startObject();
            } else {
                throw new JsonParseException("Expected value, array, or object.", parser.getCurrentLocation());
            }
        }
    }
View Full Code Here

        stack.push(node);
    }

    private void handleFieldName() throws JsonParseException, IOException {
        if (stack.isEmpty() || !(stack.peek() instanceof ObjectNode)) {
            throw new JsonParseException("Field in unexpected position", parser.getCurrentLocation());
        }
        FieldNode field = new FieldNode(parser.getCurrentName());
        pushToStack(field);
    }
View Full Code Here

            ObjectNode object = (ObjectNode) stack.peek();
            object.addField(field);
        } else if (owner instanceof ArrayNode) {
            ((ArrayNode) owner).addItem(valueNode);
        } else {
            throw new JsonParseException("Scalar value in unexpected position.", 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

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.