package com.thhy.screen.modules.biz.agv.controller; import com.alibaba.fastjson.JSON; import com.thhy.screen.modules.biz.agv.entity.AgvStateHistory; public class test { public static void main(String[] args) { String mess = "agv/tcb01/agvState{\"agvBaseAngularVel\": 0.0, \"errorCode\": 0, \"battery1Current\": 2.3, \"accurateStop\": 0, \"agvVelLevel\": \"3\", \"battery1Charge\": 96.5, \"agvModelRFID\": -1, \"agvControlStyle\": \"manu\", \"battery1ErrorCode\": 0, \"agvDestRFID\": -1, \"agvVelDirection\": \"stop\", \"agvBaseLinearVel\": 0.0, \"agvBackLaserSwitch\": 0, \"agvWorkingState\": \"idle\", \"agvLiftupHeavyState\": \"heavyNoExistence\", \"errorContent\": \"\\u624b\\u52a8\\u63a7\\u5236\\uff0c\\u72b6\\u6001\\u826f\\u597d\", \"agvId\": \"tcb01\", \"agvFrontLaserSwitch\": 0, \"agvTaskState\": \"idle\", \"agvCollision\": 0, \"agvEmergencyButton\": 0, \"agvCurrentLandmarkRFID\": -1, \"agvMoveStyle\": \"longtitude\", \"battery1Voltage\": 53.3, \"agvJackingState\": \"jackingDown\"}"; mess = mess.substring(mess.indexOf("{"),mess.indexOf("}")+1); AgvStateHistory agvStateHistory = JSON.parseObject(mess,AgvStateHistory.class); System.out.printf(mess); } }