Kong/unirest-java

The way queryString handles Map<String, List<String>>?

formatsystem opened this issue · 2 comments

Hello:
When I use the queryString(String, Map<String, Object>) method, if I pass a parameter of type Map<String, List>, the List will appear as [123] due to String.valueOf(). However, it actually needs to be in the format ["123"] to respond correctly. Currently, I check with instanceof to determine if value is a List, and if so, I use JSON.toJSONString from Fastjson 2 to serialize it before passing it as a parameter. I'm wondering if there is a better way to handle this?

Hi @formatsystem, I think maybe you are trying to do something in Unirest that should probably be done outside of it. Why not just pass unirest a string of the value you want rather than expecting a map to serialize in some specific way. That map method is really designed for things like ints and bools for use with query params, its not designed for complex objects. I'm also not sure why JSON is coming into it?

Hi @formatsystem, I think maybe you are trying to do something in Unirest that should probably be done outside of it. Why not just pass unirest a string of the value you want rather than expecting a map to serialize in some specific way. That map method is really designed for things like ints and bools for use with query params, its not designed for complex objects. I'm also not sure why JSON is coming into it?

Thank you for your explanation. It seems I shouldn't handle too much content within Unirest.