As I interpret your code, the byte array contains the keywords body, email, and password. So you can check if the bytes of the keywords do not change between different samples of byte arrays and if they do not change then you remove everything after the bytes of the password keyword. If you have another keyword after the password, then you just remove everything until this keyword.
Here is an example, how it could look like:
import java.util.ArrayList;
public class MyClass {
public static void main(String args[]) {
byte a[] = "body: [{\"email\":\"email@email.com\",\"password\":\"some_password\",.....}]".getBytes();
byte[] pass = {34,112,97,115,115,119,111,114,100,34,58,34}; //"\"password\":\"".getBytes();
byte[] end = {34,44}; //"\",".getBytes();
ArrayList<Byte> arrList= new ArrayList<Byte>();
boolean foundPassword = false;
for(int i=0;i<a.length;i++){
if (a[i] == pass[0] && a[i+1] == pass[1] && a[i+2] == pass[2] && a[i+3] == pass[3] && a[i+4] == pass[4] && a[i+5] == pass[5] && a[i+6] == pass[6] && a[i+7] == pass[7] && a[i+8] == pass[8] && a[i+9] == pass[9] && a[i+10] == pass[10] && a[i+11] == pass[11]){
i = i+12;
foundPassword = true;
} else if (!foundPassword){
arrList.add(a[i]);
} else if (foundPassword && a[i] == end[0] && a[i+1] == end[1]){
arrList.add(new Integer(44).byteValue());
foundPassword = false;
i+2;
}
}
byte[] result = new byte[arrList.size()];
for(int i=0;i<arrList.size();i++)
result[i] = arrList.get(i);
System.out.println(new String(result));
}
}
Output: body: [{"email":"email@email.com",,.....}]