第一步:在pom.xml中添加依赖;
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.47</version> </dependency>
第二步:编写测试代码;
import java.util.Map;
import com.alibaba.fastjson.JSON;
public class Demo1 {
public static void main(String[] args) {
String str = "{\"id\":11,\"status\":\"Analyze\",\"severity\":\"Review\"}";
Map<String,Object> mapType = JSON.parseObject(str,Map.class);
for (Object obj : mapType.keySet()){
System.out.println(obj+" = "+mapType.get(obj));
}
}
}
第三步:查看运行结果;
原文地址:https://www.cnblogs.com/chcha1/p/10720992.html
时间: 2024-10-09 01:16:50