package com.thhy.staff.modules.biz.platuser.entity; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.thhy.general.annotations.Idkey; import lombok.Data; import java.io.Serializable; import java.util.Date; @Data public class DoorLis implements Serializable { @Idkey private String id; private String ipAddress; private String macAddress; private Date dateTime; private int noticeType; private String name; private String employeeNoString; private int verify; private String oriStr; private Integer cmpType; private String captureScore; public DoorLis() { } public DoorLis(String oriStr) { this.oriStr = oriStr; } public DoorLis(JSONObject jsonObject) { this.macAddress = jsonObject.getString("dev_sno"); long time = jsonObject.getLong("capture_time"); this.dateTime = new Date(time); this.employeeNoString = jsonObject.getString("person_id"); this.oriStr = jsonObject.getString("capture_img"); this.cmpType = jsonObject.getInteger("cmp_type"); this.verify = jsonObject.getInteger("capture_status"); this.captureScore = jsonObject.getString("capture_score"); } public static void main(String[] args) { String mess = "{\n" + " \"dev_sno\": \" 04:12:53:FA:21:DA\",\n" + " \"token\": \"f9k4l8ds3e92w02d9c82013na0s9\",\n" + " \"person_id\": 12306,\n" + " \"person_name\": \"张三\",\n" + " \"person_temperature\": 36.7,\n" + " \"person_type\": \"1\",\n" + " \"id_card\": \"\",\n" + " \"ic_card\": \"\",\n" + " \"capture_img\": \"/9i/4aVBORw\",\n" + " \"capture_score\": \"85.64\",\n" + " \"capture_time\": \"1610967016235\",\n" + " \"capture_status\": 1\n" + "}"; JSONObject jsonObject = JSON.parseObject(mess); DoorLis doorLis = new DoorLis(jsonObject); System.out.println(doorLis.getName()); } }