0

I am writing Junit test case for my REST service, i am setting the values(below is the piece of code) to get the payload required for REST service

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);

I want JSON to be built in format mentioned below, but I am not getting the JSON as expected, details should be in form of Array.

Required JSON -

   {
  "Acc" : "A",
    "details": [
     { 
      "totalAmount":1,
      "currency":"dollar"
     }
   ]
 }

Output JSON -

 {
 "Acc" : "A",
  "details": 
   { 
     "totalAmount":1,
     "currency":"dollar"
  }
}

Can anyone help me how can I achieve this?

Nagendra
  • 191
  • 1
  • 3
  • 20

0 Answers0