How can I cast a JSONObject to a custom Java class?

后端 未结 5 761
深忆病人
深忆病人 2021-02-12 15:42

In Java (using json-simple) I have successfully parsed a JSON string which was created in JavaScript using JSON.stringify. It looks like this:

{\"teq\":14567,\"         


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-02-12 16:27

    use jackson library

        //create ObjectMapper instance
        ObjectMapper objectMapper = new ObjectMapper();
    
        //convert json string to object
        Employee emp = objectMapper.readValue(jsonData, Employee.class); 
    

提交回复
热议问题