[英]Map<String,String> Key Value on Postman
I am currently build a controller that will accept an parameter with Map i need to pass it through form-data because of Multipart File.我目前正在构建一个 controller ,它将接受带有 Map 的参数,由于多部分文件,我需要通过表单数据传递它。 I cannot pass a Map on postman, it keeps giving me this error
我无法在 postman 上传递 Map,它一直给我这个错误
"Failed to convert property value of type java.lang.String to required type java.util.Map for property variables; nested exception is java.lang.IllegalStateException: Cannot convert value of type java.lang.String to required type java.util.Map for property variables: no matching editors or conversion strategy found"
This is what i currently pass on PostMan这是我目前通过 PostMan
Key钥匙
variables
Value价值
variables : {"abc": "123"}
you need to deserialize that string.您需要反序列化该字符串。 Maybe you want to take a look at something like GSON to convert that JSON string into your Java
Map<String, String>
https://github.com/google/gson Maybe you want to take a look at something like GSON to convert that JSON string into your Java
Map<String, String>
https://github.com/google/gson
It should be something like this:它应该是这样的:
String someJSONMap = "{\"abc\":\"123\"}";
Gson gson = new Gson();
Type type = new TypeToken<HashMap<String, String>>(){}.getType();
Map<String,String> result = gson.fromJson(someJSONMap, type);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.