【README】
本文po出了 如何读取 字节数组到jsonobject;
字节数组如何获取,本文不再赘述;
【1】代码
/*** @Description 字节数组转json演示* @author xiao tang* @version 1.0.0* @createTime 2022年02月11日*/
public class ByteArr2JsonDemo {public static void main(String[] args) {byte[] arr = "{\"name\":\"你好\"}".getBytes(StandardCharsets.UTF_8);JSONObject jsonObject = (JSONObject) JSONObject.parse(arr, 0, arr.length, StandardCharsets.UTF_8.newDecoder(), new Feature[0]);System.out.println(jsonObject.toJSONString());}
}
打印结果:
{"name":"你好"}