JSON转Object
String str="{\"val\": \"蓝色\",\"name\": \"颜色\"}"; ProductDetailSpec jsonObject = JSONObject.parseObject(str,ProductDetailSpec.class);//json对象转字符串 System.out.println(jsonObject.getVal());
JSON转list集合
//str 是重数据库查的一个集合,用String 接收的 List<ProductDetailSpec> pSec = pSec = JSON.parseObject(str, new TypeReference<List<ProductDetailSpec>>() {});