code: @SuppressWarnings("checkstyle:cyclomaticcomplexity")
      private static String escapeString(final String str) {
          final StringBuilder sb = new StringBuilder(str.length());
  
          for (final char ch : str.toCharArray()) {
              switch (ch) {
                  case QUOTE:
                  case '\\':
                  case '/':
                      sb.append('\\');
                      sb.append(ch);
                      break;
                  case '\b':
                      sb.append("\\b");
                      break;
                  case '\f':
                      sb.append("\\f");
                      break;
                  case '\n':
                      sb.append("\\n");
                      break;
                  case '\r':
                      sb.append("\\r");
                      break;
                  case '\t':
                      sb.append("\\t");
                      break;
                  default:
                      sb.append(ch < ' ' ? escapeCharacter(ch) : ch);
              }
          }
  
          return sb.toString();
      }
docs: Escape characters in string, if required per RFC-7159 (JSON).
  
  @param str string to be escaped.
  @return escaped string.