convert JSON Type to Byte array format in java

前端 未结 4 771
萌比男神i
萌比男神i 2021-02-05 02:25

I have a problem when I want to sending data using byte format in UDP protocol, the problem is when I try to create a data with type json object, I can\'t get the byte format of

4条回答
  •  野性不改
    2021-02-05 02:38

    Assuming the JSONObject you mention is from this, you can get the bytes like below

    sendData = obj.toString().getBytes("utf-8");
    

提交回复
热议问题