Hi Tatu,
here is a little runnable file which shows my problem. I can make it work
the delegation to the JsonCreator (commented out in SetDeviseId) but I was
hoping to avoid this.
Hopefully you can point me to what I am missing or doing wrong. Thanks so
much.
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;
public class MyProblem {
ObjectMapper mapper;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include =
JsonTypeInfo.As.WRAPPER_ARRAY, property = "name")
@JsonTypeName("radius-avp")
static public class RadiusAvp {
public String attribute;
public RadiusAvp() {
}
public RadiusAvp(String attribute) {
this.attribute = attribute;
}
public String toString() {
return "radius-avp = " + attribute;
}
}
@JsonTypeName("transform-rule")
static public class TransformRule {
public TransformRule() {
}
@JsonProperty("actions")
public List<SetDeviceId> actions;
public String toString() {
return "Transform-rule: " + actions.toString();
}
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include =
JsonTypeInfo.As.WRAPPER_ARRAY, property = "name")
@JsonTypeName("set-device-id")
static public class SetDeviceId {
public RadiusAvp radiusAvp;
public SetDeviceId() {
}
// Uncomment this section to make this work (but we don't like this)
//
// @JsonCreator
// public SetDeviceId(Object object) {
// ObjectMapper mapper = new ObjectMapper();
// radiusAvp = mapper.convertValue(object, RadiusAvp.class);
// }
public String toString() {
return "set-device-id: " + radiusAvp.toString();
}
}
public static void main(String[] args) throws Exception {
String json =
"{\"actions\":[[\"set-device-id\",[\"radius-avp\",\"nas-identifier\"]]]}";
ObjectMapper mapper = new ObjectMapper();
TransformRule transformRule = mapper.readValue(json,
TransformRule.class);
System.out.println(transformRule.toString());
}
}
On Tuesday, November 12, 2019 at 3:11:30 PM UTC-8, Tatu Saloranta wrote:
>
> On Mon, Nov 11, 2019 at 7:13 PM Guido Rost <[email protected]
> <javascript:>> wrote:
> >
> >
> > I just posted the upper level class which contains the actions.
> > The target type is SetDeviceId which contains a field of type RadiusAvp.
> The construction of that is the actual problem
>
> Yes, please do tell me what I really need.
>
> -+ Tatu +-
>
> >
> > --
> > 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] <javascript:>.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/jackson-user/e88ec00a-e3f1-453f-8eaf-f3fd83cf8422%40googlegroups.com.
>
>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/35ebdc5e-8084-4347-8280-06bd42127877%40googlegroups.com.