I have a request coming like this
{
"varA" : "A",
"varB" : "TCFNhbiBKb3NlMRgwFgYDVQQK"
}
where key varB is a base64 encoded JSON string. something like this:
{
"nestedVarB1": "some value here",
"nestedVarB2" : "some other value here"
}
I want to convert it into some POJOs like this:
@Data
public class MyRequest {
private String varA;
private B varB;
}
@Data
public class B {
private String nestedVarB1;
private String nestedVarB2;
}
I went through several solutions on stack overflow like this and this, but I want to convert the JSON directly into an object of type MyRequest maybe by writing some sort of Jackson deserializer.
How can I convert the JSON directly into MyRequest using Jackson and Spring Boot?
Note:
- POJOs
MyRequestandBare very big andBcould be further nested, so doing it manually would be a big task. - I don't have any control over the request coming, it is coming from a third party source. So, can't change the format of the request.