JSONArray byteArrayToJSON(byte[] byteArray) {
JSONArray jsonArray= new JSONArray();
for (byte byteValue : byteArray) {
jsonArray.put(byteValue );
}
return jsonArray;
}
byte[] jsonToByteArray(JSONArray jsonArray) throws JSONException {
byte[] byteArray = new byte[jsonArray.length()];
for (int i = 0; i < jsonArray.length(); i++) {
byteArray[i] = (byte) jsonArray.getInt(i);
}
return byteArray;
}

0 Comments