當前位置: 首頁>>代碼示例>>Java>>正文


Java JacksonConverterFactory類代碼示例

本文整理匯總了Java中retrofit2.converter.jackson.JacksonConverterFactory的典型用法代碼示例。如果您正苦於以下問題:Java JacksonConverterFactory類的具體用法?Java JacksonConverterFactory怎麽用?Java JacksonConverterFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JacksonConverterFactory類屬於retrofit2.converter.jackson包,在下文中一共展示了JacksonConverterFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
@Before public void setUp() {
  SimpleModule module = new SimpleModule();
  module.addSerializer(AnInterface.class, new AnInterfaceSerializer());
  module.addDeserializer(AnInterface.class, new AnInterfaceDeserializer());
  ObjectMapper mapper = new ObjectMapper();
  mapper.registerModule(module);
  mapper.configure(MapperFeature.AUTO_DETECT_GETTERS, false);
  mapper.configure(MapperFeature.AUTO_DETECT_SETTERS, false);
  mapper.configure(MapperFeature.AUTO_DETECT_IS_GETTERS, false);
  mapper.setVisibilityChecker(mapper.getSerializationConfig()
      .getDefaultVisibilityChecker()
      .withFieldVisibility(JsonAutoDetect.Visibility.ANY));

  Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(server.url("/"))
      .addConverterFactory(JacksonConverterFactory.create(mapper))
      .build();
  service = retrofit.create(Service.class);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:JacksonConverterFactoryTest.java

示例2: getApiService

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
/**
 * Gets api service.
 *
 * @param enableHTTPLogging boolean to enable logging
 * @return the bot api service
 */
public static TelegramBotApiService getApiService(Boolean enableHTTPLogging) {
    if (ApiService == null) {
        Logger.info("No instance of service yet. Building...");
        ObjectMapper objectMapper = new ObjectMapper().registerModule(new Jdk8Module());
        Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
                .baseUrl("https://api.telegram.org/bot" + Token + "/")
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(JacksonConverterFactory.create(objectMapper));
        if (enableHTTPLogging) {
            Logger.info("Adding request logging...");
            HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
            httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
            OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
            httpClient.addInterceptor(httpLoggingInterceptor);
            retrofitBuilder.client(httpClient.build());
        }
        Retrofit retrofit = retrofitBuilder.build();
        ApiService = retrofit.create(TelegramBotApiService.class);
    }
    Logger.debug("Returning ApiService instance.");
    return ApiService;
}
 
開發者ID:iSDP,項目名稱:Telebot,代碼行數:29,代碼來源:Telebot.java

示例3: ClientAPI

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
private ClientAPI() {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient.Builder client = new OkHttpClient.Builder();
    client.addInterceptor(logging);
    client.addInterceptor(new ErrorInterceptor());
    client.addInterceptor(new BearerTokenHeaderInterceptor());

    retrofit = new Retrofit.Builder()
            .baseUrl("http://" + BASE_URL)
            .addConverterFactory(JacksonConverterFactory.create())
            .client(client.build())
            .build();

}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:17,代碼來源:ClientAPI.java

示例4: ClientAPI

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
private ClientAPI() {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient.Builder client = new OkHttpClient.Builder();
    client.addInterceptor(logging);
    client.addInterceptor(new BearerTokenHeaderInterceptor());
    client.addInterceptor(new ErrorInterceptor());

    retrofit = new Retrofit.Builder()
            .baseUrl("http://" + BASE_URL)
            .addConverterFactory(JacksonConverterFactory.create())
            .client(client.build())
            .build();

}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:17,代碼來源:ClientAPI.java

示例5: ClientAPI

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
private ClientAPI(OAuth2ClientAuthenticationInterceptor clientAuthentication) {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient.Builder client = new OkHttpClient.Builder();
    client.addInterceptor(logging);
    client.addInterceptor(new ErrorInterceptor());
    client.addInterceptor(new BearerTokenHeaderInterceptor());

    if (clientAuthentication != null) {
        client.addInterceptor(clientAuthentication);
    }

    retrofit = new Retrofit.Builder()
            .baseUrl("http://" + BASE_URL)
            .addConverterFactory(JacksonConverterFactory.create())
            .client(client.build())
            .build();
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:20,代碼來源:ClientAPI.java

示例6: ClientAPI

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
private ClientAPI(OAuth2ClientAuthenticationInterceptor basicAuthentication) {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    OkHttpClient.Builder client = new OkHttpClient.Builder();
    client.addInterceptor(logging);
    client.addInterceptor(new ErrorInterceptor());
    client.addInterceptor(new BearerTokenHeaderInterceptor());

    if (basicAuthentication != null) {
        client.addInterceptor(basicAuthentication);
    }

    retrofit = new Retrofit.Builder()
            .baseUrl("http://" + BASE_URL)
            .addConverterFactory(JacksonConverterFactory.create())
            .client(client.build())
            .build();
}
 
開發者ID:PacktPublishing,項目名稱:OAuth-2.0-Cookbook,代碼行數:20,代碼來源:ClientAPI.java

示例7: createService

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
public static TwitterService createService(String consumerKey, String consumerSecret, String token, String secret)
{
    OkHttpOAuthConsumer consumer = new OkHttpOAuthConsumer(consumerKey, consumerSecret);
    consumer.setTokenWithSecret(token, secret);

    OkHttpClient client = new OkHttpClient.Builder()
            .addInterceptor(new SigningInterceptor(consumer))
            .build();

    return new Retrofit.Builder()
            .baseUrl("https://api.twitter.com/1.1/")
            .addConverterFactory(JacksonConverterFactory.create())
            .client(client)
            .build()
            .create(TwitterService.class);
}
 
開發者ID:prestodb-rocks,項目名稱:presto-rest,代碼行數:17,代碼來源:TwitterServiceFactory.java

示例8: AbstractRemoteClient

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
/**
 * Class constructor that allows setting timeout parameters
 */
protected AbstractRemoteClient(EndpointConnector connector, Class<S> cls) {
    Preconditions.checkNotNull(connector, "Passed connector is null for " + this.getClass().getSimpleName());
    this.connector = connector;

    // Extended timeouts are needed to deal with extremely slow response times for some Argus API endpoints.
    OkHttpClient client;
    
    // set HTTP proxy, if configured
    if (connector.isProxyEnabled()) {
        client = httpClientBuilder(connector).proxy(createProxy(connector)).build();
    } else {
        client = httpClientBuilder(connector).build();
    }

    // build the retrofit service implementation, using a specified client and relying on Jackson serialization/deserialization
    retrofit = new Retrofit.Builder()
            .baseUrl(connector.endpoint())
            .client(client)
            .addConverterFactory(JacksonConverterFactory.create())
            .build();

    this.svc = retrofit.create(cls);
}
 
開發者ID:salesforce,項目名稱:pyplyn,代碼行數:27,代碼來源:AbstractRemoteClient.java

示例9: ApiFactory

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
public ApiFactory(String baseUrl) {
    HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
    logging.setLevel(HttpLoggingInterceptor.Level.BODY);

    this.okHttpClient = new OkHttpClient.Builder().readTimeout(60, TimeUnit.SECONDS)
                                                  .connectTimeout(60, TimeUnit.SECONDS)
                                                  .cookieJar(new SimpleCookieJar())
                                                  .addInterceptor(logging)
                                                  .build();
    this.retrofit = new Retrofit.Builder().baseUrl(baseUrl)
                                          .addConverterFactory(JacksonConverterFactory.create(
                                                  new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
                                                                    .setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE)
                                                                    .setVisibility(PropertyAccessor.FIELD,
                                                                            JsonAutoDetect.Visibility.ANY))) // 配置Json序列化的時候隻使用field name,不走getter setter
                                          .client(okHttpClient)
                                          .build();
}
 
開發者ID:Lovelcp,項目名稱:Easy-WeChat,代碼行數:19,代碼來源:ApiFactory.java

示例10: yummlyApi

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
@Provides
@Singleton
static YummlyApi yummlyApi(YummlyConfig config) {
  return new ArmeriaRetrofitBuilder()
      .baseUrl("http://api.yummly.com/v1/api/")
      .addCallAdapterFactory(GuavaCallAdapterFactory.create())
      .addConverterFactory(JacksonConverterFactory.create(OBJECT_MAPPER))
      .withClientOptions(
          (unused, options) ->
              options
                  .addHttpHeader(HttpHeaderNames.of("X-Yummly-App-ID"), config.getApiId())
                  .addHttpHeader(HttpHeaderNames.of("X-Yummly-App-Key"), config.getApiKey())
                  .decorator(HttpRequest.class, HttpResponse.class, LoggingClient.newDecorator()))
      .build()
      .create(YummlyApi.class);
}
 
開發者ID:curioswitch,項目名稱:curiostack,代碼行數:17,代碼來源:YummlyApiModule.java

示例11: JiraService

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
public JiraService(final Site jiraSite) {
  this.jiraSite = jiraSite;

  final ConnectionPool CONNECTION_POOL = new ConnectionPool(5, 60, TimeUnit.SECONDS);

  OkHttpClient httpClient = new OkHttpClient.Builder()
      .connectTimeout(jiraSite.getTimeout(), TimeUnit.MILLISECONDS)
      .readTimeout(10000, TimeUnit.MILLISECONDS).connectionPool(CONNECTION_POOL)
      .retryOnConnectionFailure(true).addInterceptor(new SigningInterceptor(jiraSite)).build();

  final ObjectMapper mapper = new ObjectMapper();
  mapper.registerModule(new JodaModule());
  this.jiraEndPoints = new Retrofit.Builder().baseUrl(this.jiraSite.getUrl().toString())
      .addConverterFactory(JacksonConverterFactory.create(mapper))
      .addCallAdapterFactory(RxJavaCallAdapterFactory.create()).client(httpClient).build()
      .create(JiraEndPoints.class);
}
 
開發者ID:jenkinsci,項目名稱:jira-steps-plugin,代碼行數:18,代碼來源:JiraService.java

示例12: setup

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
@Before
public void setup() throws IOException {
    mockWebServer = new MockWebServer();
    mockWebServer.start();

    ObjectMapper objectMapper = new ObjectMapper().disable(
            MapperFeature.AUTO_DETECT_CREATORS,
            MapperFeature.AUTO_DETECT_FIELDS,
            MapperFeature.AUTO_DETECT_GETTERS,
            MapperFeature.AUTO_DETECT_IS_GETTERS)
            .configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);

    DeltaApi deltaApi = new Retrofit.Builder()
            .baseUrl(mockWebServer.url("").toString())
            .addConverterFactory(JacksonConverterFactory.create(objectMapper))
            .build()
            .create(DeltaApi.class);

    apiClient = new DeltaApiClient(deltaApi);
}
 
開發者ID:Covata,項目名稱:delta-sdk-java,代碼行數:21,代碼來源:DeltaApiClientTest.java

示例13: setup

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
@Before
public void setup() throws IOException {
    MockWebServer mockWebServer = new MockWebServer();
    mockWebServer.start();

    JacksonConverterFactory converterFactory = JacksonConverterFactory.create(new ObjectMapper());

    mockDeltaApi = new Retrofit.Builder()
            .baseUrl(mockWebServer.url(MOCK_HOST).toString())
            .addConverterFactory(converterFactory)
            .build().create(MockDeltaApi.class);

    CreateIdentityRequest createIdentityRequest =
            new CreateIdentityRequest(SIGNING_PUBLIC_KEY, ENCRYPTION_PUBLIC_KEY, null, null);
    Call<CreateIdentityResponse> call
            = mockDeltaApi.register(REQUEST_DATE,
            "example.server", IDENTITY_ID, "sampleQueryParamValue", createIdentityRequest);
    request = call.request()
            .newBuilder() // fix as okhttp removes content-type header
            .addHeader(HttpHeaders.CONTENT_TYPE, MediaType.JSON_UTF_8.toString())
            .build();
}
 
開發者ID:Covata,項目名稱:delta-sdk-java,代碼行數:23,代碼來源:AuthorizationUtilTest.java

示例14: RetrofitClient

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
private RetrofitClient() {

        mOkHttpClient = new OkHttpClient
                .Builder()
//                .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                .addInterceptor(this)
                .build();

        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(NetworkConstants.NETWORK_BASE_URL)
                .addConverterFactory(JacksonConverterFactory.create(APIConstants.getInstance().getObjectMapper()))
                .client(mOkHttpClient)
                .build();

        mApiClient = retrofit.create(APIClient.class);
    }
 
開發者ID:hkuadithya,項目名稱:MovieManiac,代碼行數:17,代碼來源:RetrofitClient.java

示例15: Retrofit2Delegate

import retrofit2.converter.jackson.JacksonConverterFactory; //導入依賴的package包/類
public Retrofit2Delegate(String baseUrl, OkHttpClient okHttpClient, long visitDuration,
        final DeviceInfo deviceInfo) {
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    Retrofit retrofit = new Retrofit.Builder()
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(JacksonConverterFactory.create(mapper))
            .baseUrl(baseUrl)
            .client(okHttpClient)
            .build();

    this.api = retrofit.create(ApiRetrofit2.class);
    this.deviceInfo = deviceInfo;
    this.visitDuration = visitDuration;
}
 
開發者ID:instacart,項目名稱:ahoy-android,代碼行數:17,代碼來源:Retrofit2Delegate.java


注:本文中的retrofit2.converter.jackson.JacksonConverterFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。