{"value":"77","valuetype": 2,"time": 1605850493.569,"name": "ANA1093","net": 2,"qds": 4,"changenum": 0,"freshtime": 0}
请用java取出该map中的value
我看你发的string,更加像JSON数据,如果需要解析这个字符串那么只需要转对象即可
注意这里使用到了阿里的fastjson依赖
String str = "{\"value\":\"77\",\"valuetype\": 2,\"time\": 1605850493.569,\"name\": \"ANA1093\",\"net\": 2,\"qds\": 4,\"changenum\": 0,\"freshtime\": 0}";
JSONObject jsonObject = JSONObject.parseObject(str);
System.out.println(jsonObject.get("value"));
System.out.println(jsonObject.get("valuetype"));
System.out.println(jsonObject.get("time"));
如果你的真是map容器并且你想用获取全部value那么你需要使用迭代器
Map<String,Object> map = new HashMap<>();
map.put("value","77");
map.put("valuetype",2);
map.put("time",1605850493.569);
map.put("name","ANA1093");
Iterator<String> iterator = map.keySet().iterator();
while (iterator.hasNext()){
String key = iterator.next();
System.out.println("key="+key+" value="+map.get(key));
}
map.get("value");
map.values();