当前位置: 首页>>代码示例>>Java>>正文


Java JsonObjectParser类代码示例

本文整理汇总了Java中com.google.api.client.json.JsonObjectParser的典型用法代码示例。如果您正苦于以下问题:Java JsonObjectParser类的具体用法?Java JsonObjectParser怎么用?Java JsonObjectParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JsonObjectParser类属于com.google.api.client.json包,在下文中一共展示了JsonObjectParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteInstanceId

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
private Task<Void> deleteInstanceId(final String instanceId) {
  checkArgument(!Strings.isNullOrEmpty(instanceId), "instance ID must not be null or empty");
  return ImplFirebaseTrampolines.submitCallable(app, new Callable<Void>(){
    @Override
    public Void call() throws Exception {
      String url = String.format(
          "%s/project/%s/instanceId/%s", IID_SERVICE_URL, projectId, instanceId);
      HttpRequest request = requestFactory.buildDeleteRequest(new GenericUrl(url));
      request.setParser(new JsonObjectParser(jsonFactory));
      request.setResponseInterceptor(interceptor);
      HttpResponse response = null;
      try {
        response = request.execute();
        ByteStreams.exhaust(response.getContent());
      } catch (Exception e) {
        handleError(instanceId, e);
      } finally {
        if (response != null) {
          response.disconnect();
        }
      }
      return null;
    }
  });
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:26,代码来源:FirebaseInstanceId.java

示例2: signInWithCustomToken

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
private String signInWithCustomToken(String customToken) throws IOException {
  GenericUrl url = new GenericUrl(ID_TOOLKIT_URL + "?key="
      + IntegrationTestUtils.getApiKey());
  Map<String, Object> content = ImmutableMap.<String, Object>of(
      "token", customToken, "returnSecureToken", true);
  HttpRequest request = transport.createRequestFactory().buildPostRequest(url,
      new JsonHttpContent(jsonFactory, content));
  request.setParser(new JsonObjectParser(jsonFactory));
  HttpResponse response = request.execute();
  try {
    GenericJson json = response.parseAs(GenericJson.class);
    return json.get("idToken").toString();
  } finally {
    response.disconnect();
  }
}
 
开发者ID:firebase,项目名称:firebase-admin-java,代码行数:17,代码来源:FirebaseAuthIT.java

示例3: constructHttpRequest

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
private HttpRequest constructHttpRequest(final String content) throws IOException {
  HttpTransport transport = new MockHttpTransport() {
    @Override
    public LowLevelHttpRequest buildRequest(String method, String url) throws IOException {
      return new MockLowLevelHttpRequest() {
        @Override
        public LowLevelHttpResponse execute() throws IOException {
          MockLowLevelHttpResponse result = new MockLowLevelHttpResponse();
          result.setContentType("application/json");
          result.setContent(content);
          return result;
        }
      };
    }
  };
  return transport.createRequestFactory().buildGetRequest(new GenericUrl("https://google.com"))
      .setParser(new JsonObjectParser(new JacksonFactory()));
}
 
开发者ID:cloudendpoints,项目名称:endpoints-java,代码行数:19,代码来源:GoogleAuthTest.java

示例4: getHttpRequestFactory

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
/**
 * TODO(malcon): Consolidate GitHub and this one in one class
 */
private HttpRequestFactory getHttpRequestFactory(@Nullable UserPassword userPassword)
    throws RepoException, ValidationException {
  return httpTransport.createRequestFactory(
      request -> {
        request.setConnectTimeout((int) Duration.ofMinutes(1).toMillis());
        request.setReadTimeout((int) Duration.ofMinutes(1).toMillis());
        HttpHeaders httpHeaders = new HttpHeaders();
        if (userPassword != null) {
          httpHeaders.setBasicAuthentication(userPassword.getUsername(),
                                             userPassword.getPassword_BeCareful());
        }
        request.setHeaders(httpHeaders);
        request.setParser(new JsonObjectParser(JSON_FACTORY));
      });
}
 
开发者ID:google,项目名称:copybara,代码行数:19,代码来源:GerritApiTransportImpl.java

示例5: getTokenFromCode

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
private void getTokenFromCode(final String code) throws IOException {

        log.debug("Fetching authorisation token using authorisation code");
        HttpRequest request =
                HTTP_TRANSPORT.createRequestFactory().buildGetRequest(new GenericUrl("https://login.live.com/oauth20_token.srf") {
                    @Key("client_id")
                    private String id = clientId;
                    @Key("client_secret")
                    private String secret = clientSecret;
                    @Key("code")
                    private String authCode = code;
                    @Key("grant_type")
                    private String grantType = "authorization_code";
                    @Key("redirect_uri")
                    private String redirect = "https://login.live.com/oauth20_desktop.srf";
                });

        request.setParser(new JsonObjectParser(JSON_FACTORY));

        processResponse(request.execute());
    }
 
开发者ID:wooti,项目名称:onedrive-java-client,代码行数:22,代码来源:OneDriveAuthorisationProvider.java

示例6: getTokenFromRefreshToken

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
private void getTokenFromRefreshToken(final String refreshToken) throws IOException {

        log.debug("Fetching authorisation token using refresh token");

        HttpRequest request =
                HTTP_TRANSPORT.createRequestFactory().buildGetRequest(new GenericUrl("https://login.live.com/oauth20_token.srf") {
                    @Key("client_id")
                    private String id = clientId;
                    @Key("client_secret")
                    private String secret = clientSecret;
                    @Key("refresh_token")
                    private String token = refreshToken;
                    @Key("grant_type")
                    private String grantType = "refresh_token";
                    @Key("redirect_uri")
                    private String redirect = "https://login.live.com/oauth20_desktop.srf";
                });

        request.setParser(new JsonObjectParser(JSON_FACTORY));

        processResponse(request.execute());
    }
 
开发者ID:wooti,项目名称:onedrive-java-client,代码行数:23,代码来源:OneDriveAuthorisationProvider.java

示例7: ROOneDriveProvider

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
public ROOneDriveProvider(final AuthorisationProvider authoriser) {
    requestFactory =
            HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() {
                @Override
                public void initialize(HttpRequest request) {
                    request.setParser(new JsonObjectParser(JSON_FACTORY));
                    request.setReadTimeout(60000);
                    request.setConnectTimeout(60000);
                    try {
                        request.getHeaders().setAuthorization("bearer " + authoriser.getAccessToken());
                    } catch (IOException e) {
                        throw Throwables.propagate(e);
                    }

                    request.setUnsuccessfulResponseHandler(new OneDriveResponseHandler(authoriser));
                }
            });
}
 
开发者ID:wooti,项目名称:onedrive-java-client,代码行数:19,代码来源:ROOneDriveProvider.java

示例8: WikiMapiaRetriever

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
public WikiMapiaRetriever(Credentials credentials) throws Exception {
    super(credentials);

    if (credentials.getKey() == null) {
        logger.error("Wikimapia requires an API key.");
        throw new Exception("Wikimapia requires an API key.");
    }
    key = credentials.getKey();
    requestFactory = HTTP_TRANSPORT.createRequestFactory(
            new HttpRequestInitializer() {
                @Override
                public void initialize(HttpRequest request) {
                    request.setParser(new JsonObjectParser(JSON_FACTORY));
                }
            });
}
 
开发者ID:MKLab-ITI,项目名称:simmo-stream-manager,代码行数:17,代码来源:WikiMapiaRetriever.java

示例9: getGoogleIdToken

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
private static String getGoogleIdToken(String jwt) throws Exception {
  final GenericData tokenRequest =
      new GenericData().set("grant_type", JWT_BEARER_TOKEN_GRANT_TYPE).set("assertion", jwt);
  final UrlEncodedContent content = new UrlEncodedContent(tokenRequest);

  final HttpRequestFactory requestFactory = httpTransport.createRequestFactory();

  final HttpRequest request =
      requestFactory
          .buildPostRequest(new GenericUrl(OAUTH_TOKEN_URI), content)
          .setParser(new JsonObjectParser(JacksonFactory.getDefaultInstance()));

  HttpResponse response;
  String idToken = null;
  response = request.execute();
  GenericData responseData = response.parseAs(GenericData.class);
  idToken = (String) responseData.get("id_token");
  return idToken;
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:20,代码来源:BuildIapRequest.java

示例10: testBuildSettingsFromFile

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
@Test
public void testBuildSettingsFromFile() throws IOException {

    try {
        FileReader fileReader = new FileReader("src/main/resources/example_settings_1.json");
        JsonObjectParser parser = new JsonObjectParser(JSON_FACTORY);

        Settings settings = parser.parseAndClose(fileReader, Settings.class);

        assertEquals("1", settings.getId());
        assertEquals("1", settings.getApiUser());
        assertEquals("4ae0c36da907994c6458958e262c7b3f0677d035", settings.getApiToken());
        assertEquals("C:\\focus24\\temp\\", settings.getTmpDirectory());
        assertEquals("C:\\focus24\\", settings.getWorkingDirectory());
        assertEquals("http://localhost:8000/", settings.getServer_ip());
        assertEquals("mysqldump", settings.getMysqlDump());

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }

}
 
开发者ID:frecar,项目名称:ossus-client,代码行数:23,代码来源:SettingsTest.java

示例11: getRequestFactory

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
/**
 * Gets request factory.
 *
 * @param parser  the parser to use for the resulting object
 * @param headers additional request headers
 *
 * @return the request factory
 */
private HttpRequestFactory getRequestFactory(final JsonObjectParser parser, final HttpHeaders headers) {

  return getConf().getHttpTransport().createRequestFactory( new HttpRequestInitializer() {

    @Override
    public void initialize(HttpRequest request) throws IOException {
      HttpRequestInitializer c = createCredentialWithRefreshToken();
      c.initialize( request );
      request.setParser( parser == null ? jsonObjectParser : parser );
      request.setThrowExceptionOnExecuteError( false );
      request.setSuppressUserAgentSuffix( true );

      HttpHeaders head = getDefaultHeaders();
      if ( headers != null ) {
        if ( head != null ) {
          headers.fromHttpHeaders( head );
        }
        head = headers;
      }

      request.setHeaders( head );
    }
  } );
}
 
开发者ID:icoretech,项目名称:audiobox-jlib,代码行数:33,代码来源:AudioBoxClient.java

示例12: testMediaFiles

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
/**
 * Test media files.
 *
 * @throws AudioBoxException the audio box exception
 */
@Test
public void testMediaFiles() throws IOException {
  final Playlist p = Playlists.getDropboxPlaylist( c );

  p.addObserver( new Observer() {

    @Override
    public void update(Observable o, Object arg) {
      assertSame( o, p );
      assertTrue(arg instanceof ModelEvent );
      ModelEvent e = ( ModelEvent ) arg;
      assertTrue( e.source instanceof MediaFile );
      assertTrue( e.target instanceof EventedModelList);
    }

  });

  JsonObjectParser parser = new AudioBoxObjectParser( c, new MediaFiles.MediaCollectionCustomParser( p ) );
  List<? extends MediaFile> m = p.getMediaFiles( c, parser );
  assertNotNull( m );
}
 
开发者ID:icoretech,项目名称:audiobox-jlib,代码行数:27,代码来源:MediaFilesTests.java

示例13: Register

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
/**
 * @param transport HTTP transport
 * @param httpRequestInitializer HTTP request initializer or {@code null} for none
 * @param rootUrl root URL of the service
 * @param servicePath service path
 * @param jsonObjectParser JSON object parser
 * @param googleClientRequestInitializer Google request initializer or {@code null} for none
 * @param applicationName application name to be sent in the User-Agent header of requests or
 *        {@code null} for none
 * @param suppressPatternChecks whether discovery pattern checks should be suppressed on required
 *        parameters
 */
Register(HttpTransport transport,
    HttpRequestInitializer httpRequestInitializer,
    String rootUrl,
    String servicePath,
    JsonObjectParser jsonObjectParser,
    GoogleClientRequestInitializer googleClientRequestInitializer,
    String applicationName,
    boolean suppressPatternChecks) {
  super(transport,
      httpRequestInitializer,
      rootUrl,
      servicePath,
      jsonObjectParser,
      googleClientRequestInitializer,
      applicationName,
      suppressPatternChecks);
}
 
开发者ID:lolletsoc,项目名称:dissertation-project,代码行数:30,代码来源:Register.java

示例14: Widerst

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
/**
 * @param transport HTTP transport
 * @param httpRequestInitializer HTTP request initializer or {@code null} for none
 * @param rootUrl root URL of the service
 * @param servicePath service path
 * @param jsonObjectParser JSON object parser
 * @param googleClientRequestInitializer Google request initializer or {@code null} for none
 * @param applicationName application name to be sent in the User-Agent header of requests or
 *        {@code null} for none
 * @param suppressPatternChecks whether discovery pattern checks should be suppressed on required
 *        parameters
 */
Widerst(HttpTransport transport,
    HttpRequestInitializer httpRequestInitializer,
    String rootUrl,
    String servicePath,
    JsonObjectParser jsonObjectParser,
    GoogleClientRequestInitializer googleClientRequestInitializer,
    String applicationName,
    boolean suppressPatternChecks) {
  super(transport,
      httpRequestInitializer,
      rootUrl,
      servicePath,
      jsonObjectParser,
      googleClientRequestInitializer,
      applicationName,
      suppressPatternChecks);
}
 
开发者ID:lolletsoc,项目名称:dissertation-project,代码行数:30,代码来源:Widerst.java

示例15: RequestFactory

import com.google.api.client.json.JsonObjectParser; //导入依赖的package包/类
public RequestFactory(final String proto, final String host, final Integer port) {
    this.proto = proto;
    this.host = host;
    this.port = port;

    this.executeUrl = new GenericUrl(String.format("%s://%s:%d/db/execute", this.proto, this.host, this.port));
    this.queryUrl = new GenericUrl(String.format("%s://%s:%d/db/query", this.proto, this.host, this.port));
    this.statusUrl = new GenericUrl(String.format("%s://%s:%d/status", this.proto, this.host, this.port));

    this.requestFactory = HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() {
        public void initialize(HttpRequest request) {
            request.setParser(new JsonObjectParser(JSON_FACTORY));
        }
    });
}
 
开发者ID:rqlite,项目名称:rqlite-java,代码行数:16,代码来源:RequestFactory.java


注:本文中的com.google.api.client.json.JsonObjectParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。