Converting byte[] to JsonObject
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
JSONObject jsonObject = new JSONObject(IOUtils.toString(responseBody, StandardCharsets.UTF_8));
Try this :
String testV=new JSONObject(new String(responseBody)).toString();
or this if you need a JSONObject
JSONObject testV=new JSONObject(new String(responseBody));
The issue is that you declare a String
variable and intent to store a JSONObject
into it.