[{"A":0},
{"B":20}]
前端输入A测试则返回0,后端代码是什么样的呢
将 [{"A":0},{"B":20}] 转换为Map存储,当前端插入对应的Key时,通过map.get("A")获取对应的值。
如有帮助请采纳
遍历集合,根据输入的数据进行比较,然后返回。
//前端输入的字符
String str = "A";
Map<String, Object> map = new HashMap<>();
map.put("A", 0);
map.put("B", 20);
System.out.println(map.get(str));