I'm looking for a solution to serialize a POJO object property based on some other property value within the same POJO using Jackson.
If a property value matches some criteria then other property values should be changed as per requirement.
For example, below is my JSON object:
{
"testProperty": "testValue",
"object": [{
"key": "password",
"value": "passwordValue"
},
{
"key": "key2",
"value": "value2"
}]
}
In above case, if key
's value matches some criteria then I should be able to change the value of value
.
Why this is required:
object
is a configuration object- And
key
-value
are configuration settings - In the above example one of the
key
ispassword
and I need to mask/change the respectivevalue
of that.
One more point to add, here in this example the properties are key
and value
, but if we find some solution to get it applied generically to any other properties dynamically then that would be great.
Annotating the properties can be one way but haven't found any way within Jackson to do so with custom serializers.
Thanks in advance.
Any help will be appreciated.