List of usage examples for com.google.gson FieldNamingPolicy LOWER_CASE_WITH_UNDERSCORES
FieldNamingPolicy LOWER_CASE_WITH_UNDERSCORES
To view the source code for com.google.gson FieldNamingPolicy LOWER_CASE_WITH_UNDERSCORES.
Click Source Link
From source file:org.apache.sling.auth.xing.oauth.impl.XingOauthAuthenticationHandler.java
License:Apache License
protected XingUser fetchUser(final Token accessToken) throws Exception { final OAuthRequest request = new OAuthRequest(Verb.GET, usersMeUrl); oAuthService.signRequest(accessToken, request); final Response response = request.send(); final Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .create();//from w ww. j a v a 2 s . c o m final Users users = gson.fromJson(response.getBody(), Users.class); return users.getUsers().get(0); }
From source file:org.atlasapi.output.JsonTranslator.java
License:Apache License
public JsonTranslator() { this(new GsonBuilder().disableHtmlEscaping().setDateFormat(DateFormat.LONG) .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(AtlasErrorSummary.class, new AtlasExceptionJsonSerializer()) .registerTypeAdapter(Date.class, new DateTimeSerializer()) .registerTypeAdapter(Description.class, new DescriptionSerializer()) .registerTypeAdapter(DateTime.class, new JodaDateTimeSerializer())); }
From source file:org.disciplestoday.disciplestoday.SyncAdapter.java
License:Apache License
/** * get call based on moduleid/* w w w .j a va 2s. c o m*/ * @return */ public Call<Feed> getCall(String moduleId) { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build(); Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create(gson); Retrofit retrofit = new Retrofit.Builder().baseUrl(DTService.DISCIPLES_TODAY_BASE_URL).client(client) .addConverterFactory(gsonConverterFactory).build(); DTService service = retrofit.create(DTService.class); return service.listFeed(moduleId); }
From source file:org.eclipse.jgit.lfs.Protocol.java
License:Eclipse Distribution License
/** * @return a {@link Gson} instance suitable for handling this * {@link Protocol}/*from www. ja v a 2 s .co m*/ * * @since 4.11 */ public static Gson gson() { return new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .disableHtmlEscaping().create(); }
From source file:org.eclipse.jgit.lfs.server.fs.FileLfsServlet.java
License:Eclipse Distribution License
private static Gson createGson() { GsonBuilder gb = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .setPrettyPrinting().disableHtmlEscaping(); return gb.create(); }
From source file:org.eclipse.jgit.lfs.server.LfsProtocolServlet.java
License:Eclipse Distribution License
private Gson createGson() { return new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .disableHtmlEscaping().create(); }
From source file:org.eclipse.smarthome.auth.oauth2client.internal.OAuthConnector.java
License:Open Source License
public OAuthConnector(HttpClientFactory httpClientFactory) { this.httpClientFactory = httpClientFactory; gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); }
From source file:org.edx.mobile.discussion.DiscussionAPI.java
License:Open Source License
@Inject public DiscussionAPI(Context context, Config config) { this.context = context; this.config = config; Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").create(); OkHttpClient oauthBasedClient = new OkHttpClient(); File cacheDirectory = new File(context.getFilesDir(), "http-cache"); if (!cacheDirectory.exists()) { cacheDirectory.mkdirs();// www . j a v a 2 s .com } Cache cache = new com.squareup.okhttp.Cache(cacheDirectory, cacheSize); oauthBasedClient.setCache(cache); // oauthBasedClient.interceptors().add(new GzipRequestInterceptor()); oauthBasedClient.interceptors().add(new OauthHeaderRequestInterceptor(context)); oauthBasedClient.interceptors().add(new LoggingInterceptor()); RestAdapter restAdapter = new RestAdapter.Builder().setClient(new OkClient(oauthBasedClient)) .setEndpoint(config.getApiHostURL()).setConverter(new GsonConverter(gson)) // .setRequestInterceptor(new OfflineRequestInterceptor(context, 60)) .setErrorHandler(new RetroHttpExceptionHandler()).setLogLevel(RestAdapter.LogLevel.FULL).build(); discussionService = restAdapter.create(DiscussionService.class); }
From source file:org.gdg.frisbee.android.api.GdgX.java
License:Apache License
public ApiRequest checkOrganizer(String gplusId, Response.Listener<OrganizerCheckResponse> successListener, Response.ErrorListener errorListener) { GsonRequest<Void, OrganizerCheckResponse> organizerReq = new GsonRequest<>(Request.Method.GET, "http://hub.gdgx.io/api/v1/organizer/" + gplusId, OrganizerCheckResponse.class, successListener, errorListener, GsonRequest.getGson(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)); return new ApiRequest(organizerReq); }
From source file:org.gdg.frisbee.android.api.GitHub.java
License:Apache License
public ApiRequest getContributors(String user, String repo, Response.Listener<ArrayList<Contributor>> successListener, Response.ErrorListener errorListener) { Type type = new TypeToken<ArrayList<Contributor>>() { }.getType();/*from www . j a v a2 s. co m*/ String url = String.format(CONTRIBUTORS_URL, user, repo); GsonRequest<Void, ArrayList<Contributor>> eventReq = new GsonRequest<Void, ArrayList<Contributor>>( Request.Method.GET, url, type, successListener, errorListener, GsonRequest.getGson(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)); return new ApiRequest(eventReq); }