我有两个这样的jsons
{
"clientId":"patientId",
"vendorId":"businessKey"
}
{
"patientId":"1234",
"businessKey":"abcd"
}
我有像这些
创建的java POJOpublic class Patient{
private String patientId;
private String businessKey;
public String getPatientId() {
return patientId;
}
public void setPatientId(String patientId) {
this.patientId = patientId;
}
public String getBusinessKey() {
return businessKey;
}
public void setBusinessKey(String businessKey) {
this.businessKey = businessKey;
}
}
public class Client {
private String clientId;
private String vendorId;
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public String getVendorId() {
return vendorId;
}
public void setVendorId(String vendorId) {
this.vendorId = vendorId;
}
}
我使用Jackson的ObjectMapper来解析JSON。我想要实现的是首先读取第一个JSON,从中获取值,然后从第二个JSON中读取实际值。 例如:我读了第一个JSON到getClientId - “patientId” 然后在第二个JSON中我应该读取getPatientId - 1234。
如何以编程方式实现此目的。我不想通过添加很多if else块来混乱我的代码。有没有我可以使用的图书馆?