Example #1
0
  @Override
  void encode(Encoder app, Object object, Map<Object, Type> visited) throws IOException, Exception {

    // Byte arrays should not be treated as arrays. We treat them
    // as hex strings

    if (object instanceof byte[]) {
      StringHandler.string(app, Hex.toHexString((byte[]) object));
      return;
    }
    app.append("[");
    app.indent();
    String del = "";
    int l = Array.getLength(object);
    for (int i = 0; i < l; i++) {
      app.append(del);
      app.encode(Array.get(object, i), componentType, visited);
      del = ",";
    }
    app.undent();
    app.append("]");
  }