1. 首先先 导入 json 包 :jackson-mapper-asl-1.9.13 jackson-core-asl-1.9.9
2.. import java.util.List;
import org.codehaus.jackson.map.ObjectMapper;
public class jsonTest {
public static void main(String[] args) throws Exception{
String json = "[{\"pid\":1,\"count\":2},{\"pid\":1,\"count\":2},{\"pid\":1,\"count\":2}]";
ObjectMapper mapper = new ObjectMapper();
List<Object> list = mapper.readValue(json, List.class);
System.out.println(list);
}
}
打印 结果 :
[{pid=1, count=2}, {pid=1, count=2}, {pid=1, count=2}]