step1:导入相应jar包:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.41</version>
</dependency>
step2:
1.String 转为JSONObject类型
JSONObject value =JSON.parseObject((map.get(key1)));
2.JSONObject转化为String类型
JSON.toJSON(value);
3.获取JSONobject中数组类型的值
JSONObject value =JSON.parseObject((map.get(key1)));
value.getJSONArray(key).get(int index)
4.获取JSONobject中String
JSONObject value =JSON.parseObject((map.get(key1)));
value.getJSONObject.getString(key);
5.将list内容的string转为jsonarray
String orderList = orderForm.getItems();
List<OrderDetail> orderDetailList = null;
orderDetailList = JSONArray.parseArray(orderList, OrderDetail.class); //orderDetail为需要转换的实体类```