I have the following ResultSet in string format. For reasons not related to my question, I can only have it as a String. How can I create a Java POJO from this string?
{
"columnNames": [
"cc.expiryDate",
"cc.number"
],
"values": [
[
1586131200000,
"3529-2930-4919-1213"
]
]
}
Here is my POJO class:
public class CreditCard {
private String number;
private Date expiryDate;
public Date getExpiryDate() {
return this.expiryDate;
}
public void setExpiryDate(Date expiryDate) {
this.expiryDate = expiryDate;
}
public String getNumber() {
return this.number;
}
public void setNumber(String number) {
this.number = number;
}
}
I know how to do if I have a ResultSet JDBC object, I know how to do if I have a JSON columnName: value syntax but I cannot find how to do it having this string. I am not looking for developing an algorithm that uses reflection - I could do this. I am looking for using already existing libraries. I guess two options are: 1) Parse the string to create a ResultSet object or 2) Convert the string to JSON colunmName: value format. Any suggestions?