On Wed, May 17, 2017 at 3:47 PM, Kevin Brightwell <[email protected]> wrote: > Using the mix-in properties worked excellently! > > All I had to use was: > > abstract class ReadOnlyPropertyMixin { > ReadOnlyPropertyMixin(@JsonProperty("bean") Object bean, > @JsonProperty("name") String name, > @JsonProperty("value") Object value) {} > > @JsonManagedReference @JsonProperty("bean") > abstract public Object getBean(); > > @JsonProperty("name") > abstract public String getName(); > > @JsonProperty("value") > abstract public Object getValue(); > } > > Thanks for a fast response, too!
Great, glad to hear that it works. > > Along the same lines, is there a means to access the cache of known entities > when deserializing? I have multiple references to the same managed > references in different classes. The use of BackReference and > ManagedReference doesn't seem to allow for 1-many relationships. Managed/BackReference does work for 1-to-N relationships, but only if forward (managed) reference is a Collection or Map or array, but not for multiple properties. For more complex use cases full object identity (@JsonIdentityReference) is needed; it works bit different (first time instance reached it is fully serialized, including Object Id; further references only use Id [String or integral number]). -+ Tatu +- > > Kevin > > On Wednesday, 17 May 2017 13:34:57 UTC-4, Tatu Saloranta wrote: >> >> On Wed, May 17, 2017 at 10:28 AM, Kevin Brightwell >> <[email protected]> wrote: >> > Hello, >> > >> > I'm trying to implement some serializers/deserializers for JavaFX >> > properties >> > and have run into several issues: >> > >> > Jackson's annotations are not usable as the classes in JavaFX are all >> > part >> > of the JDK not my own code-base >> >> This is something that mix-in annotations should help with: you can >> associate any and all annotations on 3rd party types, without >> modifying source code (or bytecode manipulation). >> >> > There is inherent cycles in properties due to "bean references" in >> > javafx.beans.property.ReadOnlyProperty#getBean() which stores a >> > reference to >> > the "owning" bean >> > >> > My question is, how can I utilize repeated references to the bean and >> > not >> > reserialize them similar to how @JsonBackReference and >> > @JsonManagedReference >> > work without having annotations present? >> >> If it is true parent/child reference, I think using mix-in annotation >> facility would make sense here. >> Either for back/managed reference, or just ignoral. >> >> Alternatively if that does not work, you might need to drop properties >> via BeanSerializerModifier (which gets called and allows >> changing/removing/adding BeanPropertyWriter objects); but that's more >> work unless it's something as simple as just dropping specific >> property that would otherwise be included. >> >> -+ Tatu +- >> >> > >> > Thanks, >> > Kevin >> > >> > -- >> > 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. -- 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.
