public SearchOptions writeJson(JsonWriter json, long totalHits) {
    json.prop("total", totalHits);
    json.prop(WebService.Param.PAGE, getPage());
    json.prop(WebService.Param.PAGE_SIZE, getLimit());
    return this;
  }
@Test
  public void writeJson() {
    SearchOptions options = new SearchOptions().setPage(3, 10);
    StringWriter json = new StringWriter();
    JsonWriter jsonWriter = JsonWriter.of(json).beginObject();
    options.writeJson(jsonWriter, 42L);
    jsonWriter.endObject().close();

    JsonAssert.assertJson(json.toString()).isSimilarTo("{\"total\": 42, \"p\": 3, \"ps\": 10}");
  }