import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonProcessingException;
Map<String, Object> msgJson = new HashMap<String, Object>(); if (isend == true) { msgJson.put("isend", 1); }else{ msgJson.put("isend", 0); } ObjectMapper mapper = new ObjectMapper(); byte[] msgJsonByte = mapper.writeValueAsBytes(msgJson); //编码json为byte数组 ObjectMapper mapper = new ObjectMapper(); byte[] msgJsonByte = mapper.writeValueAsBytes(msgJson); //解码byte数组为json格式 ObjectMapper mapper = new ObjectMapper(); msgjson = mapper.readValue(msg, HashMap.class); if (1 == (Integer) msgJsonRece.get("refresh")) { return ((String) msgJsonRece.get("text")).getBytes(); }