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

2
  • you are posting several parts. You only need one. Commented Oct 1, 2014 at 21:17
  • Not sure what you mean? Does this solve issue with the output format? Commented Oct 1, 2014 at 21:20

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.