code: public static ExternalSessionKey fromJsonResponseBody(String responseBody) {
      try {
        Map<String, Object> json = new Json().toType(responseBody, MAP_TYPE);
        if (json.get("sessionId") instanceof String) {
          return new ExternalSessionKey((String) json.get("sessionId"));
        }
  
        // W3C response
        if (json.get("value") instanceof Map) {
          Map<?, ?> value = (Map<?, ?>) json.get("value");
          if (value.get("sessionId") instanceof String) {
            return new ExternalSessionKey((String) value.get("sessionId"));
          }
        }
      } catch (JsonException | ClassCastException e) {
        return null;
      }
  
      return null;
    }
docs: Extract the external key from the server response for a selenium2 new session request.
  The response body is expected to be of the form {"status":0,"sessionId":"XXXX",...}.
  @param responseBody the response body to parse
  @return the extracted ExternalKey, or null if one was not found.