I’m using JAX-RS to try and handle a query containing an array in a format I’m not familiar with. The query parameters appear in the following format:
?to[0]=100002700373730&to[1]=744826619&to[2]=501266190
The number of array parameters is variable. As far as I’m aware, this isn’t a normal format for passing an array. However, as I have no control over the query formatting, I have to handle it as is.
I’d hoped that there was some form of JAX-RS annotation that would allow the handling of this format of array, but that doesn’t appear to be the case. Currently I’m just getting the query parameters from the UriInfo and manually building a String array from it for processing. This solution works, but seems like a bit of a hack. If there’s a better (or more correct) way to do it then I’d definitely appreciate knowing how. Thanks! 🙂
This doesn’t look like a standard format indeed, so MultivaluedMap sounds like the best way to go (although you can directly get it as a method argument w/o going through the UriInfo API).