congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
GsonBuilder.setLenient
Code IndexAdd Tabnine to your IDE (free)

How to use
setLenient
method
in
com.google.gson.GsonBuilder

Best Java code snippets using com.google.gson.GsonBuilder.setLenient (Showing top 20 results out of 315)

origin: GitLqr/LQRWeChat

private ApiRetrofit() {
  super();
  Gson gson = new GsonBuilder()
      .setLenient()
      .create();
  //在构造方法中完成对Retrofit接口的初始化
  mApi = new Retrofit.Builder()
      .baseUrl(MyApi.BASE_URL)
      .client(getClient())
      .addConverterFactory(GsonConverterFactory.create(gson))
      .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
      .build()
      .create(MyApi.class);
}
origin: jphp-group/jphp

@Signature(@Arg(value = "flags", optional = @Optional("0")))
public Memory __construct(Environment env, Memory... args) {
  int flags = args[0].toInteger();
  if ((flags & SERIALIZE_PRETTY_PRINT) == SERIALIZE_PRETTY_PRINT) {
    builder.setPrettyPrinting();
  }
  if ((flags & DESERIALIZE_LENIENT) == DESERIALIZE_LENIENT) {
    builder.setLenient();
  }
  if ((flags & DESERIALIZE_AS_ARRAYS) == DESERIALIZE_AS_ARRAYS) {
    memoryDeserializer.setAssoc(true);
  }
  if (flags > 0) {
    gson = builder.create();
  }
  return Memory.NULL;
}
origin: gazbert/bxbot

/**
 * Initialises the GSON layer.
 */
private void initGson() {
  gson = new GsonBuilder()
      .setLenient() //since all names in json starts upper case 
      .create();
}

origin: org.aksw.jena-sparql-api/jena-sparql-api-sparql-ext

public RDFDatatypeJson(String uri) {
  this(uri, new GsonBuilder().setLenient().create());
}
origin: SmartDataAnalytics/jena-sparql-api

public RDFDatatypeJson(String uri) {
  this(uri, new GsonBuilder().setLenient().create());
}
origin: WangDaYeeeeee/Mysplash

private FeedApi buildApi(OkHttpClient client) {
  return new Retrofit.Builder()
      .baseUrl(Mysplash.UNSPLASH_URL)
      .client(client)
      .addConverterFactory(
          GsonConverterFactory.create(
              new GsonBuilder().setLenient().create()))
      .build()
      .create((FeedApi.class));
}
origin: WangDaYeeeeee/Mysplash

private NotificationApi buildApi(OkHttpClient client) {
  return new Retrofit.Builder()
      .baseUrl(Mysplash.UNSPLASH_URL)
      .client(client)
      .addConverterFactory(
          GsonConverterFactory.create(
              new GsonBuilder().setLenient().create()))
      .build()
      .create((NotificationApi.class));
}
origin: WangDaYeeeeee/GeometricWeather

private BaiduLocationApi buildApi() {
  return new Retrofit.Builder()
      .baseUrl(BuildConfig.BAIDU_IP_LOCATION_BASE_URL)
      .addConverterFactory(
          GsonConverterFactory.create(
              new GsonBuilder().setLenient().create()))
      .client(buildClient())
      .build()
      .create((BaiduLocationApi.class));
}
origin: WangDaYeeeeee/GeometricWeather

private CNWeatherApi buildApi() {
  return new Retrofit.Builder()
      .baseUrl(BuildConfig.CN_WEATHER_BASE_URL)
      .addConverterFactory(
          GsonConverterFactory.create(
              new GsonBuilder().setLenient().create()))
      .client(buildClient())
      .build()
      .create((CNWeatherApi.class));
}
origin: charbgr/SeismicInterceptor

public static Retrofit build() {
  OkHttpClient okHttpClient = new OkHttpClient.Builder()
      .addInterceptor(SeismicInterceptor.create())
      .build();
  GsonBuilder gsonBuilder = new GsonBuilder();
  gsonBuilder.setLenient();
  return new Retrofit.Builder()
      .baseUrl(API_URL)
      .client(okHttpClient)
      .addConverterFactory(GsonConverterFactory.create(gsonBuilder.create()))
      .build();
}
origin: majunm/HttpX

public static IGsonFactory2 create() {
  return create(new GsonBuilder().setLenient().create());
}
origin: vpaliy/last.fm-api

private Retrofit provideRetrofit(OkHttpClient okHttpClient) {
  Gson gson = new GsonBuilder()
      .setLenient()
      .registerTypeAdapterFactory(new Adapter())
      .create();
  return new Retrofit.Builder()
      .baseUrl(baseUrl)
      .addConverterFactory(GsonConverterFactory.create(gson))
      .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
      .client(okHttpClient)
      .build();
}
origin: azhon/Mvp-RxJava-Retrofit

public BaseApiImpl(String baseUrl) {
  retrofitBuilder.addConverterFactory(ScalarsConverterFactory.create())
      .addConverterFactory(GsonConverterFactory.create(new GsonBuilder()
          .setLenient()
          .create()
      ))
      .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
      .client(httpBuilder.addInterceptor(getLoggerInterceptor()).build())
      .baseUrl(baseUrl);
}
origin: WangDaYeeeeee/GeometricWeather

public AccuWeatherService() {
  OkHttpClient client = getClientBuilder()
      .addInterceptor(new GzipInterceptor())
      // .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
      .build();
  client.dispatcher().setMaxRequestsPerHost(1);
  this.api = new Retrofit.Builder()
      .baseUrl(BuildConfig.ACCU_WEATHER_BASE_URL)
      .addConverterFactory(GsonConverterFactory.create(
          new GsonBuilder().setLenient().create()))
      .client(client)
      .build()
      .create((AccuWeatherApi.class));
}
origin: WangDaYeeeeee/GeometricWeather

public CaiYunWeatherService() {
  OkHttpClient client = getClientBuilder()
      .addInterceptor(new GzipInterceptor())
      // .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
      .build();
  client.dispatcher().setMaxRequestsPerHost(1);
  this.api = new Retrofit.Builder()
      .baseUrl(BuildConfig.CAIYUN_WEATHER_BASE_URL)
      .addConverterFactory(
          GsonConverterFactory.create(
              new GsonBuilder().setLenient().create()))
      .client(client)
      .build()
      .create((CaiYunApi.class));
}
origin: googlegenomics/dockerflow

/** Deserialize from json. */
public static <T> T fromJson(String s, Class<T> c) throws IOException {
 FileUtils.LOG.debug("Deserializing from json to " + c);
 T retval;
 // For some reason, this only works for auto-generated Google API
 // classes
 if (c.toString().startsWith("com.google.api.services.")) {
  FileUtils.LOG.debug("Using Google APIs JsonParser");
  retval = Utils.getDefaultJsonFactory().createJsonParser(s).parse(c);
 } else {
  FileUtils.LOG.debug("Using Gson");
  retval = new GsonBuilder().setLenient().create().fromJson(s, c);
 }
 return retval;
}
origin: yangchong211/YCAudioPlayer

/**
 * 第一种方式
 * @return              Gson对象
 */
public static Gson getJson() {
  if (gson == null) {
    GsonBuilder builder = new GsonBuilder();
    builder.setLenient();
    builder.setFieldNamingStrategy(new AnnotateNaming());
    builder.serializeNulls();
    gson = builder.create();
  }
  return gson;
}
origin: jruesga/rview

  public static GsonBuilder createGerritGsonBuilder(
      boolean nonExecutable, PlatformAbstractionLayer abstractionLayer) {
    GsonBuilder builder = new GsonBuilder()
        .setVersion(GerritApi.API_VERSION)
        .registerTypeAdapter(Date.class, new GerritUtcDateAdapter())
        .registerTypeAdapter(ServerVersion.class, new GerritServerVersionAdapter())
        .registerTypeAdapter(ApprovalInfo.class, new GerritApprovalInfoAdapter())
        .registerTypeAdapter(Base64Data.class, new GerritBas64Adapter(abstractionLayer))
        .setLenient();
    if (nonExecutable) {
      builder.generateNonExecutableJson();
    }
    return builder;
  }
}
origin: Cognifide/aet

public ClientSidePerformanceComparatorResultData parse(String json) throws ProcessingException {
 Type type = new TypeToken<ClientSidePerformanceReport>() {
 }.getType();
 try {
  ClientSidePerformanceReport report = new GsonBuilder().setLenient().create()
    .fromJson(json, type);
  ComparatorStepResult.Status result = getResultStatus(report.getPrettyOverallScore());
  return new ClientSidePerformanceComparatorResultData(result, report);
 } catch (JsonSyntaxException e) {
  throw new ProcessingException(e.getMessage(), e);
 }
}
origin: com.cognifide.aet/jobs

public ClientSidePerformanceComparatorResultData parse(String json) throws ProcessingException {
 Type type = new TypeToken<ClientSidePerformanceReport>() {
 }.getType();
 try {
  ClientSidePerformanceReport report = new GsonBuilder().setLenient().create()
    .fromJson(json, type);
  ComparatorStepResult.Status result = getResultStatus(report.getPrettyOverallScore());
  return new ClientSidePerformanceComparatorResultData(result, report);
 } catch (JsonSyntaxException e) {
  throw new ProcessingException(e.getMessage(), e);
 }
}
com.google.gsonGsonBuildersetLenient

Javadoc

By default, Gson is strict and only accepts JSON as specified by RFC 4627. This option makes the parser liberal in what it accepts.

Popular methods of GsonBuilder

  • create
    Creates a Gson instance based on the current configuration. This method is free of side-effects to t
  • <init>
    Constructs a GsonBuilder instance from a Gson instance. The newly constructed GsonBuilder has the sa
  • registerTypeAdapter
  • setPrettyPrinting
    Configures Gson to output Json that fits in a page for pretty printing. This option only affects Jso
  • serializeNulls
    Configure Gson to serialize null fields. By default, Gson omits all fields that are null during seri
  • disableHtmlEscaping
    By default, Gson escapes HTML characters such as < > etc. Use this option to configure Gson to pass-
  • setDateFormat
    Configures Gson to serialize Date objects according to the pattern provided. You can call this metho
  • registerTypeAdapterFactory
    Register a factory for type adapters. Registering a factory is useful when the type adapter needs to
  • setFieldNamingPolicy
    Configures Gson to apply a specific naming policy to an object's field during serialization and dese
  • registerTypeHierarchyAdapter
  • excludeFieldsWithoutExposeAnnotation
    Configures Gson to exclude all fields from consideration for serialization or deserialization that d
  • setExclusionStrategies
    Configures Gson to apply a set of exclusion strategies during both serialization and deserialization
  • excludeFieldsWithoutExposeAnnotation,
  • setExclusionStrategies,
  • enableComplexMapKeySerialization,
  • addSerializationExclusionStrategy,
  • excludeFieldsWithModifiers,
  • serializeSpecialFloatingPointValues,
  • setVersion,
  • setFieldNamingStrategy,
  • addTypeAdaptersForDate

Popular in Java

  • Making http requests using okhttp
  • onCreateOptionsMenu (Activity)
  • getSystemService (Context)
  • getContentResolver (Context)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • JFrame (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now