我正在为我的REST服务编写Junit测试用例,我正在设置值(下面是一段代码)以获取REST服务所需的有效负载
Payload jsonPayload = new Payload ();
payload.setAcc("A");
List<Details> details= new ArrayList<Details>;
Details detail = new Details();
detail.setTotalAmount(1);
detail.setCurrency("dollar");
details.add(detail);
payload.getDetails().addAll(details);
我希望JSON以下面提到的格式构建,但我没有按预期获得JSON,详细信息应该是Array格式。
必需的JSON -
{
"Acc" : "A",
"details": [
{
"totalAmount":1,
"currency":"dollar"
}
]
}
输出JSON -
{
"Acc" : "A",
"details":
{
"totalAmount":1,
"currency":"dollar"
}
}
任何人都可以帮助我如何实现这一目标?