You're right, that works. Now it looks way better. But there is no way of 
Jackson creating SetDeviceId without the @JsonCreator annotation? 
Thanks  a lot ,
Guido

On Thursday, November 14, 2019 at 3:18:43 PM UTC-8, Tatu Saloranta wrote:
>
> By quick look, would it not work if you declared type of delegated thing 
> as `RadiusAvp`, not Object?
>
> And if serialization needed, adding `@JsonValue` on that RadiusAvp field.
>
> -+ Tatu +-
>
>
> On Tue, Nov 12, 2019 at 9:52 PM Guido Rost <[email protected] 
> <javascript:>> wrote:
>
>> 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]> 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]. 
>>> > 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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jackson-user/35ebdc5e-8084-4347-8280-06bd42127877%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jackson-user/35ebdc5e-8084-4347-8280-06bd42127877%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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/f3efba48-41d6-4455-980b-e9d75231ed85%40googlegroups.com.

Reply via email to