I tried to get my byte[]
value from JSONObject
using following code but I am not getting original byte[]
value.
JSONAr
This might be of help for those using Java 8. Make use of java.util.Base64
.
Encoding byte array to String :
String encodedString = java.util.Base64.getEncoder().encodeToString(byteArray);
JSONObject.put("encodedString",encodedString);
Decode byte array from String :
String encodedString = (String) JSONObject.get("encodedString");
byte[] byteArray = java.util.Base64.getDecoder().decode(encodedString);