简体   繁体   English

Map<string,string> Postman 上的键值</string,string>

[英]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.

相关问题 将 key=value 的字符串解析为 Map - Parse a String of key=value to a Map 地图 <String, Map<String, String> &gt;-使用流选择值键 - Map<String, Map<String, String>> - Select key of value using Stream Java Map 向 postman 发送响应时省略空字符串值 - Java Map empty string value is omitted when sending response to postman 用 Map 值中的字符串替换 Map 键中的字符串 - Replace string in Map key with string from Map value 在地图内通过键获取价值 <String, Map<String, Double> &gt; JSP - Get value by key inside a Map<String, Map<String, Double>> JSP 路线:将双精度数组字符串转换为字符串,字符串(键和值)的映射 - itinerary: making double array String into a Map of String, String (Key & Value) 为什么是地图的键(或值) <String, String> 不以字符串形式返回? - Why is key (or value) of Map<String, String> not returned as String? 转换列表<String>到地图<String, List<String> &gt; 以列表值为映射键,以空列表为映射值 java 8 - Convert List<String> to Map<String, List<String>> with list value as map key and map value with empty list java 8 将java Map转换为自定义key = value字符串 - Convert java Map to custom key=value string 使用key = String和value = ArrayList创建映射<Double> - Create a map with key=String and value=ArrayList<Double>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM