Hi,
This isn't really related to Vertx. You
must know what's in your JsonArray. The only thing to do is to silence this warning on the call by putting this @SuppressWarnings("unchecked") before.
JsonArray is a list of Objects.
But you can serialize a list of JsonArray if you want, as a class member by implementing ClusterSerializable and its read and write methods.
Here's a sample with a Set<String>
public void writeToBuffer(Buffer buff) {
buff.appendInt(set == null ? 0 : set.size());
if (set != null) {
for (String entry : set) {
byte[] bytes = entry.getBytes(StandardCharsets.UTF_8);
buff.appendInt(bytes.length).appendBytes(bytes);
}
}
}
public int readFromBuffer(int pos, Buffer buffer) {
int num = buffer.getInt(pos);
pos += 4;
for (int i = 0; i < num; i++) {
int len = buffer.getInt(pos);
pos += 4;
byte[] bytes = buffer.getBytes(pos, pos + len);
pos += len;
set.add(new String(bytes, StandardCharsets.UTF_8));
}
return pos;
}