2
I am using the Jackson library to transform the following JSON into a Java object.
{"name":"Agent/MetricsReported/count","begin":"2014-02-04T09:44:00Z","end":"2014-02-04T09:45:00Z","app":"","agent_id":, "average_exclusive_time":0.23999999463558197}
My problem is that all JSON fields are fixed except the last (average_exclusive_time
). It may have another name according to a parameter passed in the request of a web service.
Is there any way to set up the Jackson library for it to mask this last dynamic value for a field called value
or maybe to a Map
.
What I want to avoid is having to create a class for every possible variation of this last field that can assume other names.
This solution has worked. I noticed that if I create the setters of the other attributes, it will only enter @Jsonanysetter for the attributes that do not have Setter.
– Renato Dinhani
@Renatodinhaniconceição That’s right. I improved the answer to try to make it clearer.
– utluiz