字节数组转jsonobject(如读取HttpServletRequest.inputstream到jsonobject)
生活随笔
收集整理的這篇文章主要介紹了
字节数组转jsonobject(如读取HttpServletRequest.inputstream到jsonobject)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
【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":"你好"}
總結
以上是生活随笔為你收集整理的字节数组转jsonobject(如读取HttpServletRequest.inputstream到jsonobject)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 网页设计怎么添加视频教程(网页设计怎么添
- 下一篇: 网站的二维码怎么变小(网站的二维码怎么变