docs: static void escapeJson(final String s, final StringBuilder buf) {
      final int length = s.length();
      int extra = 0;
      // First count how many extra chars we'll need, if any.
      for (int i = 0; i < length; i++) {
        final char c = s.charAt(i);
        switch (c) {
          case '"':
          case '\\':
          case '\b':
          case '\f':
          case '\n':
          case '\r':
          case '\t':
            extra++;
            continue;
        }
        if (c < 0x001F) {
          extra += 4;
        }
      }
      if (extra == 0) {
        buf.append(s);  // Nothing to escape.
        return;
      }
      buf.ensureCapacity(buf.length() + length + extra);
      for (int i = 0; i < length; i++) {
        final char c = s.charAt(i);
        switch (c) {
          case '"':  buf.append('\\').append('"');  continue;
          case '\\': buf.append('\\').append('\\'); continue;
          case '\b': buf.append('\\').append('b');  continue;
          case '\f': buf.append('\\').append('f');  continue;
          case '\n': buf.append('\\').append('n');  continue;
          case '\r': buf.append('\\').append('r');  continue;
          case '\t': buf.append('\\').append('t');  continue;
        }
        if (c < 0x001F) {
          buf.append('\\').append('u').append('0').append('0')
            .append((char) Const.HEX[(c >>> 4) & 0x0F])
            .append((char) Const.HEX[c & 0x0F]);
        } else {
          buf.append(c);
        }
      }
    }