Converting byte value retrieved using N1QLto java object

When I retrieve rows through N1QL using java sdk, what I get is byteValue because I am saving binary data instead of json and I don’t want to change that.

while (i.hasNext()) {
            N1qlQueryRow row =;
            byte[] b = row.byteValue();
            ByteArrayInputStream bis = new ByteArrayInputStream(b);
            try {
                ObjectInputStream in = new ObjectInputStream(bis);
                List<User> list = (List<User>)in.readObject();
            } catch (Exception e) {
      "Error -------- {}", e.getMessage());

I get the exception - invalid stream header: 7B0A2020
I can’t successfully convert the byte value to java object. The exception occurs while creating ObjectInputStream.

N1ql works only for json.

@subhashni So what purpose does row.byteValue() serve when the byte value can not be de-serialized?

When using N1ql on Json, the query returns a byte array that can be deserialized into Json. N1ql doesn’t parse binary.

Yes, I missed to read the documentation. It can’t parse binary. Thanks.