import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
public class StringToJSON {
public static void main(String[] args) {
String jsonStr = "{\"age\":22,\"name\":\"易学教程\",\"sex\":\"male\"}";
Employee e = (Employee) JSON.parseObject(jsonStr, Employee.class);
System.out.println("json字符串转简单java对象:"+e.toString());
String jsonStr2 = "[{\"age\":22,\"name\":\"易学教程\",\"sex\":\"male\"},{\"age\":23,\"name\":\"易学教程2\",\"sex\":\"male\"},{\"age\":25,\"name\":\"易学教程3\",\"sex\":\"male\"}]";
JSONObject.parseObject(jsonStr2, new TypeReference<List<Employee>>(){});
System.out.println(list);