code: public static URI toJsonApiUri(final URI uri, final String context, final String path) {
          String p = path;
          if (!p.matches("(?i)https?://.*")) p = join(context, p);
   
          if (!p.contains("?")) {
              p = join(p, "api/json");
          } else {
              final String[] components = p.split("\\?", 2);
              p = join(components[0], "api/json") + "?" + components[1];
          }
          return uri.resolve("/").resolve(p.replace(" ", "%20"));
      }
docs: Create a JSON URI from the supplied parameters.
  @param uri the server URI
  @param context the server context if any
  @param path the specific API path
  @return new full URI instance