JSON出力形式でも同様の問題に直面しました。このコードは、上記の JSON 形式で機能しました。
package com.test.ameba;
import java.util.List;
public class OutputRanges {
public List<Range> OutputRanges;
public String Message;
public String Entity;
/**
* @return the outputRanges
*/
public List<Range> getOutputRanges() {
return OutputRanges;
}
/**
* @param outputRanges the outputRanges to set
*/
public void setOutputRanges(List<Range> outputRanges) {
OutputRanges = outputRanges;
}
/**
* @return the message
*/
public String getMessage() {
return Message;
}
/**
* @param message the message to set
*/
public void setMessage(String message) {
Message = message;
}
/**
* @return the entity
*/
public String getEntity() {
return Entity;
}
/**
* @param entity the entity to set
*/
public void setEntity(String entity) {
Entity = entity;
}
}
package com.test;
public class Range {
public String Name;
/**
* @return the name
*/
public String getName() {
return Name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
Name = name;
}
public Object[] Value;
/**
* @return the value
*/
public Object[] getValue() {
return Value;
}
/**
* @param value the value to set
*/
public void setValue(Object[] value) {
Value = value;
}
}
package com.test.ameba;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JSONTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String jsonString ="{\"OutputRanges\":[{\"Name\":\"ABF_MEDICAL_RELATIVITY\",\"Value\":[[1.3628407124839714]]},{\"Name\":\" ABF_RX_RELATIVITY\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_Unique_ID_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_FIRST_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_AMEBA_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_Effective_Date_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_AMEBA_MODEL\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_UC_ER_COPAY_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_INN_OON_DED_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_COINSURANCE_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_PCP_SPEC_COPAY_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_INN_OON_OOP_MAX_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_IP_OP_COPAY_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_PHARMACY_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]},{\"Name\":\" ABF_PLAN_ADMIN_ERR\",\"Value\":[[\"CPD\",\"SL Limit\",\"Concat\",1,1.5,2,2.5,3]]}],\"Message\":\"\",\"Entity\":null}";
ObjectMapper mapper = new ObjectMapper();
OutputRanges OutputRanges=null;
try {
OutputRanges = mapper.readValue(jsonString, OutputRanges.class);
} catch (JsonParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("OutputRanges :: "+OutputRanges);;
System.out.println("OutputRanges.getOutputRanges() :: "+OutputRanges.getOutputRanges());;
for (Range r : OutputRanges.getOutputRanges()) {
System.out.println(r.getName());
}
}
}