JSON字符串转JSON对象
JSONObject jsonObject=JSON.parseObject(str);
对象转JSON字符串
String jsonStr=JSON.toJSONString(xxx);
data={name:'jack',age:'18',sex:'maie'};
data是一个对象:
Employee emp=JSON.parseObject(JSON.toJSONString(data)),Employee.class);
data是一个集合:
List<Employee> emp=JSON.parseArray(JSON.toJSONString(data)),Employee.class);
调用其他服务获取的data,本服务先添加entity,也可根据返回类型强转(不推荐)