protected void handleMissingEndArrayForSingle(JsonParser p, DeserializationContext ctxt) throws IOException { ctxt.reportWrongTokenException(this, JsonToken.END_ARRAY, "Attempted to unwrap '%s' value from an array (with `DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS`) but it contains more than one value", handledType().getName()); // 05-May-2016, tatu: Should recover somehow (maybe skip until END_ARRAY); // but for now just fall through }
protected <BOGUS> BOGUS _reportWrongToken(DeserializationContext context, JsonToken exp, String unit) throws IOException { context.reportWrongTokenException((JsonDeserializer<?>)this, exp, "Expected %s for '%s' of %s value", exp.name(), unit, handledType().getName()); return null; }
ctxt.reportWrongTokenException(rootType, JsonToken.START_OBJECT, "Current token not START_OBJECT (needed to unwrap root name '%s'), but %s", expSimpleName, p.getCurrentToken()); ctxt.reportWrongTokenException(rootType, JsonToken.FIELD_NAME, "Current token not FIELD_NAME (to contain expected root name '%s'), but %s", expSimpleName, p.getCurrentToken()); ctxt.reportWrongTokenException(rootType, JsonToken.END_OBJECT, "Current token not END_OBJECT (to match wrapper object with root name '%s'), but %s", expSimpleName, p.getCurrentToken());
ctxt.reportWrongTokenException(rootType, JsonToken.START_OBJECT, "Current token not START_OBJECT (needed to unwrap root name '%s'), but %s", expSimpleName, p.getCurrentToken()); ctxt.reportWrongTokenException(rootType, JsonToken.FIELD_NAME, "Current token not FIELD_NAME (to contain expected root name '%s'), but %s", expSimpleName, p.getCurrentToken()); ctxt.reportWrongTokenException(rootType, JsonToken.END_OBJECT, "Current token not END_OBJECT (to match wrapper object with root name '%s'), but %s", expSimpleName, p.getCurrentToken());
protected String _locateTypeId(JsonParser p, DeserializationContext ctxt) throws IOException { if (!p.isExpectedStartArrayToken()) { // Need to allow even more customized handling, if something unexpected seen... // but should there be a way to limit this to likely success cases? if (_defaultImpl != null) { return _idResolver.idFromBaseType(); } ctxt.reportWrongTokenException(baseType(), JsonToken.START_ARRAY, "need JSON Array to contain As.WRAPPER_ARRAY type information for class "+baseTypeName()); return null; } // And then type id as a String JsonToken t = p.nextToken(); if (t == JsonToken.VALUE_STRING) { String result = p.getText(); p.nextToken(); return result; } if (_defaultImpl != null) { return _idResolver.idFromBaseType(); } ctxt.reportWrongTokenException(baseType(), JsonToken.VALUE_STRING, "need JSON String that contains type id (for subtype of %s)", baseTypeName()); return null; }
protected Object _deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { final TreeNode treeNode = p.readValueAsTree(); final TreeNode typeNode = treeNode.path("type"); if (!typeNode.isObject()) { ctxt.reportWrongTokenException(typeNode.traverse(), JsonToken.START_OBJECT, "expected START_OBJECT before the type information and deserialized value"); } final TreeNode valueNode = typeNode.path("@value"); if (!valueNode.isValueNode()) { ctxt.reportWrongTokenException(typeNode.traverse(), JsonToken.VALUE_STRING, "expected VALUE_STRING as type information and deserialized value"); } final JsonParser jsonParser = valueNode.traverse(); final String typeId = jsonParser.nextTextValue(); final JsonDeserializer<Object> deser = _findDeserializer(ctxt, typeId); final JsonParser newParser = treeNode.traverse(); if (newParser.nextToken() != JsonToken.START_OBJECT) { ctxt.reportWrongTokenException(newParser, JsonToken.START_OBJECT, "expected START_OBJECT"); } return deser.deserialize(newParser, ctxt); } }
ctxt.reportWrongTokenException(this, JsonToken.FIELD_NAME, null);
ctxt.reportWrongTokenException(this, JsonToken.FIELD_NAME, null);
ctxt.reportWrongTokenException(baseType(), JsonToken.FIELD_NAME, "need JSON String that contains type id (for subtype of "+baseTypeName()+")"); ctxt.reportWrongTokenException(baseType(), JsonToken.START_OBJECT, "need JSON Object to contain As.WRAPPER_OBJECT type information for class "+baseTypeName()); ctxt.reportWrongTokenException(baseType(), JsonToken.END_OBJECT, "expected closing END_OBJECT after type information and deserialized value");
/** * Helper method used by standard deserializer. * * @since 2.3 */ public TokenBuffer deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { if (p.getCurrentTokenId() != JsonToken.FIELD_NAME.id()) { copyCurrentStructure(p); return this; } /* 28-Oct-2014, tatu: As per [databind#592], need to support a special case of starting from * FIELD_NAME, which is taken to mean that we are missing START_OBJECT, but need * to assume one did exist. */ JsonToken t; writeStartObject(); do { copyCurrentStructure(p); } while ((t = p.nextToken()) == JsonToken.FIELD_NAME); if (t != JsonToken.END_OBJECT) { ctxt.reportWrongTokenException(TokenBuffer.class, JsonToken.END_OBJECT, "Expected END_OBJECT after copying contents of a JsonParser into TokenBuffer, got "+t); // never gets here } writeEndObject(); return this; }
ctxt.reportWrongTokenException(this, JsonToken.FIELD_NAME, null);
return result; ctxt.reportWrongTokenException(this, JsonToken.FIELD_NAME, null);
return; ctxt.reportWrongTokenException(this, JsonToken.FIELD_NAME, null);
ctxt.reportWrongTokenException(this, JsonToken.END_ARRAY, "Unexpected JSON values; expected at most %d properties (in JSON Array)", propCount);
ctxt.reportWrongTokenException(this, JsonToken.END_ARRAY, "Unexpected JSON values; expected at most %d properties (in JSON Array)", propCount);
ctxt.reportWrongTokenException(this, JsonToken.END_ARRAY, "Unexpected JSON values; expected at most %d properties (in JSON Array)", propCount);
ctxt.reportWrongTokenException(this, JsonToken.END_ARRAY, "Unexpected JSON value(s); expected at most %d properties (in JSON Array)", propCount);
ctxt.reportWrongTokenException(baseType(), JsonToken.END_ARRAY, "expected closing END_ARRAY after type information and deserialized value");
ctxt.reportWrongTokenException(this, JsonToken.END_OBJECT, "Attempted to unwrap '%s' value", handledType().getName());
deserializationContext.reportWrongTokenException(jp, JsonToken.FIELD_NAME, null); deserializationContext.reportWrongTokenException(jp, JsonToken.FIELD_NAME, null);