package com.thhy.staff.modules.biz.face.entity; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; public class FaceUtils { public static FaceDevice toFaceDevice(String json){ JSONObject jsonObject = JSON.parseObject(json); FaceDevice faceDevice = JSON.toJavaObject(jsonObject,FaceDevice.class); return faceDevice; } public static void main(String[] args) { String mess = "{\n" + " \"detectAlive\": \"IRAlive\",\n" + " \"dev_sno\": \"FF:0C:F4:12:67:05\",\n" + " \"device_ip\": \"192.168.1.135\",\n" + " \"distance\": 4,\n" + " \"isFirst\": true,\n" + " \"name\": \"Terminal\",\n" + " \"openIRWindow\": false,\n" + " \"register_no\": \"12\",\n" + " \"retryInterval\": 2,\n" + " \"sign_type\": \"dev_sign\",\n" + " \"threshold\": 70,\n" + " \"throughType\": \"2\",\n" + " \"type\": 1\n" + "}"; FaceDevice faceDevice = toFaceDevice(mess); } }