Ok, so, one thing I missed; this is wrong:

@JsonIdentityInfo(generator = ObjectIdGenerators.None.class)

as `None` here means "disable ObjectId handling". So even if you never
generate Object Ids, there has to be handler. `StringIdGenerator` fits
the bill I think.

There was another problem, but I was able to make issue #123 work (fix
will be in 2.9.9 / 2.10.0) for this simple case. So it is possible
this particular usage might work with new version.

-+ Tatu +-


On Mon, Feb 18, 2019 at 10:27 PM Tatu Saloranta <[email protected]> wrote:
>
> Ok, yes, I can reproduce this, and no, it should fail. Issue now:
>
> https://github.com/FasterXML/jackson-dataformats-text/issues/123
>
> -+ Tatu +-
>
> On Fri, Feb 15, 2019 at 9:32 AM John Passaro <[email protected]> wrote:
> >
> > Here is my best attempt at a minimal example:
> >
> > class YamlScratch {
> >
> >     private static final String YAML_CONTENT = "" +
> >         "foo: &foo\n" +
> >         "  value: bar\n" +
> >         "boo: *foo\n";
> >
> >     public static void main(String[] args) throws Exception {
> >         ScratchModel yamlScratch = new ObjectMapper(
> >             new YAMLFactory()
> >         ).readValue(YAML_CONTENT, ScratchModel.class);
> >         System.out.printf("foo = %s, boo=%s%n", yamlScratch.foo, 
> > yamlScratch.boo);
> >     }
> >
> >     @JsonIdentityInfo(generator = ObjectIdGenerators.None.class)
> >     public static class ScratchModel {
> >         @JsonProperty("foo")
> >         StringHolder foo;
> >
> >         @JsonProperty("boo")
> >         StringHolder boo;
> >     }
> >     @JsonIdentityInfo(generator = ObjectIdGenerators.None.class)
> >     public static class StringHolder {
> >         @JsonProperty("value")
> >         String value;
> >
> >         @Override
> >         public String toString() {
> >             return value;
> >         }
> >     }
> > }
> >
> > Output:
> >
> > Exception in thread "main" 
> > com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot 
> > construct instance of `YamlScratch$StringHolder` (although at least one 
> > Creator exists): no String-argument constructor/factory method to 
> > deserialize from String value ('foo')
> >  at [Source: (StringReader); line: 3, column: 6] (through reference chain: 
> > YamlScratch$ScratchModel["boo"])
> >     at 
> > com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:63)
> >     at 
> > com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1329)
> >     at 
> > com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1031)
> >     at 
> > com.fasterxml.jackson.databind.deser.ValueInstantiator._createFromStringFallbacks(ValueInstantiator.java:370)
> >     at 
> > com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createFromString(StdValueInstantiator.java:314)
> >     at 
> > com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromString(BeanDeserializerBase.java:1351)
> >     at 
> > com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:170)
> >     at 
> > com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:161)
> >     at 
> > com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:136)
> >     at 
> > com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:287)
> >     at 
> > com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
> >     at 
> > com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4001)
> >     at 
> > com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2992)
> >     at YamlScratch.main(scratch_8.java:17)
> >
> > Attached screenshot shows Jackson libraries and versions being referenced - 
> > short version is that everything is 2.9.1, but jackson-annotations for some 
> > reason is 2.9.0. This doesn't seem to stop any other Jackson functionality 
> > from working, so I suspect it is not the problem, but I'm highlighting it 
> > for you just in case.
> >
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "jackson-user" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to