I believe you want your MainHash with same key in MainArray.
So, you can try,
for (String item : array_items) {
entity.addPart("MainHash[MyArray][]", new StringBody(item));
}
It will create,
[one,two,three]
as an array.
質問
I need my HTTP params should be
Parameters: {"MainHash"=>{"MyArray"=>[one,two,three]}}
For that I have tried
Try (1)
for (String item : array_items) {
entity.addPart("MainHash[MyArray[]]", new StringBody(item));
}
Result
Parameters: {"MainHash"=>{"MyArray"=>[nil,nil,nil]}} //nil for each item
Try (2)
entity.addPart("MainHash[MyArray[]]", new StringBody("["+items_string+"]"));
Result
Parameters: {"MainHash"=>{"MyArray"=>"[one,two,three]"}} //quotes added to array
When I tried it with list with out hash it is working.
But I need to append list inside hash.
Any suggestions on the same are highly appreciated.
解決
I believe you want your MainHash with same key in MainArray.
So, you can try,
for (String item : array_items) {
entity.addPart("MainHash[MyArray][]", new StringBody(item));
}
It will create,
[one,two,three]
as an array.