Here you can find the source of bytes2Json(byte[] bytes, long len, int from, int to)
public static JSONObject bytes2Json(byte[] bytes, long len, int from, int to)
//package com.java2s; import org.json.JSONException; import org.json.JSONObject; public class Main { public static JSONObject bytes2Json(byte[] bytes, long len, int from, int to) { JSONObject jsonResult = null;//w w w. j a va 2s . c o m byte[] jsonByte = new byte[(int) len]; for (int i = from, j = 0; i < to; i++, j++) { jsonByte[j] = bytes[i]; } String strJson = new String(jsonByte); try { jsonResult = new JSONObject(strJson); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jsonResult; } }