Great!

That name "generator" is a bit misleading, "handler" as you just put it
seems more apt but I imagine you're stuck with it? I assumed "generator"
meant "for serialization" and I was not (usually am not) looking to
serialize to YAML, but I don't remember reading the javadoc super closely
so it's possible I missed this detail that a generator is needed even for
deserialization.

I would love to test some more complicated examples sooner rather than
later. Do you expect to release 2.9.9 in this next two days? If not, I will
check out the appropriate branch in jackson-dataformats-text and add a test
case as you did for #123; if there is a preferable method, please let me
know.

I'm very grateful for your work on Jackson and especially on this issue.
Thank you so much!

On Thu, Feb 21, 2019, 02:05 Tatu Saloranta <[email protected]> wrote:

> 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 a topic in the
> Google Groups "jackson-user" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jackson-user/b3ucK2emRbE/unsubscribe.
> To unsubscribe from this group and all its topics, 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