You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Over in #66, a working example is posted for using the SnakeYAML engine to deserialize with Jackson. However, while this works to produce a MappingIterator, the general contract for ObjectMapper#readValue is broken:
ObjectMapper mapper = new ObjectMapper(new YAMLFactory()).findAndRegisterModules()
mapper.readValue(EntitySchema.getResourceAsStream('entitySchemas.yml'), new TypeReference<List<EntitySchema>>() {})
This produces an exception:
Caused by: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token
at [Source: (BufferedInputStream); line: 2, column: 1]
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1343)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1139)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1093)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.handleNonArray(CollectionDeserializer.java:332)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:265)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3077)
... 1 more
I'm opening this issue here because it appears to be a case where the ObjectMapper isn't delegating properly when provided with an explicit factory.
The text was updated successfully, but these errors were encountered:
@chrylis No, this seems to work as intended -- readValue() is limited to a single document and is not designed or intended to support binding over multiple documents. It does not do that for json either (where newline-separated content can be viewed as a sequence of documents.
To read content from multiple logical YAML documents, MappingIterator approach (or a sequence of separate readValue() calls) is needed.
Okay, I think I can see the data model here, and it makes sense, but it wasn't the obvious interpretation to me. Perhaps a mention of the "multiple documents != single document with a list of objects" model in the documentation would be helpful.
@chrylis Yes I totally agree that distinction is not something that is well surfaced, and should be documented better. I think I'll create a doc issue to try to outline this with YAML.
Over in #66, a working example is posted for using the SnakeYAML engine to deserialize with Jackson. However, while this works to produce a
MappingIterator
, the general contract forObjectMapper#readValue
is broken:This produces an exception:
I'm opening this issue here because it appears to be a case where the
ObjectMapper
isn't delegating properly when provided with an explicit factory.The text was updated successfully, but these errors were encountered: