class JsonWriter implements DataWriter<JsonWriteOptions> {

  private static final JsonWriter INSTANCE = new JsonWriter();
  private static final ObjectMapper mapper =
      new ObjectMapper().registerModule(new JavaTimeModule());

  static {
    register(Table.defaultWriterRegistry);
  }

  public static void register(WriterRegistry registry) {
    registry.registerExtension("json", INSTANCE);
    registry.registerOptions(JsonWriteOptions.class, INSTANCE);
  }

  public void write(Table table, JsonWriteOptions options) {<FILL_FUNCTION_BODY>}

  @Override
  public void write(Table table, Destination dest) {
    write(table, JsonWriteOptions.builder(dest).build());
  }
}

    ArrayNode output = mapper.createArrayNode();
    if (options.asObjects()) {
      for (int r = 0; r < table.rowCount(); r++) {
        ObjectNode row = mapper.createObjectNode();
        for (int c = 0; c < table.columnCount(); c++) {
          row.set(table.column(c).name(), mapper.convertValue(table.get(r, c), JsonNode.class));
        }
        output.add(row);
      }
    } else {
      if (options.header()) {
        ArrayNode row = mapper.createArrayNode();
        for (int c = 0; c < table.columnCount(); c++) {
          row.add(mapper.convertValue(table.column(c).name(), JsonNode.class));
        }
        output.add(row);
      }
      for (int r = 0; r < table.rowCount(); r++) {
        ArrayNode row = mapper.createArrayNode();
        for (int c = 0; c < table.columnCount(); c++) {
          row.add(mapper.convertValue(table.get(r, c), JsonNode.class));
        }
        output.add(row);
      }
    }
    try (Writer writer = options.destination().createWriter()) {
      String str = mapper.writeValueAsString(output);
      writer.write(str);
    } catch (IOException e) {
      throw new RuntimeIOException(e);
    }
  
<no_super_class>