0

I need to post some data to a server in this format

dates: [{...},{...},{...}]

So far I have done this

for(RepeatEventItem item : selected_dates){
   pEntity.addPart("dates[]", new StringBody(mapper.writeValueAsString(item)));
}

and the resulting format is this

["{...}","{...}"]

how can I get rid of the quotes as the server is expecting JSONObjects in the array not strings

user2611073
  • 77
  • 2
  • 9

1 Answers1

1

You can do this with a two dimensional array

for(int i = 0; i < selectdated_dates.size(); i++){
    RepeatEventItem item = selected_dates.get(i);
    pEntity.addPart("dates["+i+"][]", new StringBody(mapper.writeValueAsString(item)));
}

The result will be in the format you want.

Amanni
  • 1,924
  • 6
  • 31
  • 51