public static <T> T safeFromJson(final String jsonString, final Class<T> clazz) { GsonBuilder builder = new GsonBuilder(); Gson gson = builder.excludeFieldsWithoutExposeAnnotation().create(); try { return gson.fromJson(jsonString, clazz); } catch (Exception e) { return null; } } }
public static String toJsonString(Object object) { Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); return gson.toJson(object); }
private static String toJsonString(Object object) { Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); return gson.toJson(object); }
private static String toJsonString(Object object) { Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); return gson.toJson(object); }
@Autowired public FeatureToggleRepository(SystemEnvironment environment) { this.environment = environment; gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); }
public static <T> T fromJson(final String jsonString, final Class<T> clazz) { return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(jsonString, clazz); }
public String createRequest() { Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().serializeNulls().create(); return gson.toJson(this.transformData()); } }
static { GsonBuilder builder = new GsonBuilder(); ... builder.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC);** builder.excludeFieldsWithoutExposeAnnotation(); sExposeGson = builder.create(); }
public DeviceRepository(String deviceDb) { super(); gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .create(); repositoryPath = null; repositoryPath = Paths.get(deviceDb); setupParams(repositoryPath, ".bk", "device.db-"); nextId = 0; _loadRepository(repositoryPath); }
public GroupRepository(String groupDb) { super(); gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .create(); nextId = 0; try { repositoryPath = null; repositoryPath = Paths.get(groupDb); setupParams(repositoryPath, ".bk", "group.db-"); _loadRepository(repositoryPath); } catch (Exception ex) { groups = new HashMap<String, GroupDescriptor>(); } }
@Override public Observable<Boolean> seedDatabaseOptions() { GsonBuilder builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); final Gson gson = builder.create(); return mDbHelper.isOptionEmpty() .concatMap(new Function<Boolean, ObservableSource<? extends Boolean>>() { @Override public ObservableSource<? extends Boolean> apply(Boolean isEmpty) throws Exception { if (isEmpty) { Type type = new TypeToken<List<Option>>() { } .getType(); List<Option> optionList = gson.fromJson( CommonUtils.loadJSONFromAsset(mContext, AppConstants.SEED_DATABASE_OPTIONS), type); return saveOptionList(optionList); } return Observable.just(false); } }); }
@Override public Observable<Boolean> seedDatabaseQuestions() { GsonBuilder builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); final Gson gson = builder.create(); return mDbHelper.isQuestionEmpty() .concatMap(new Function<Boolean, ObservableSource<? extends Boolean>>() { @Override public ObservableSource<? extends Boolean> apply(Boolean isEmpty) throws Exception { if (isEmpty) { Type type = $Gson$Types .newParameterizedTypeWithOwner(null, List.class, Question.class); List<Question> questionList = gson.fromJson( CommonUtils.loadJSONFromAsset(mContext, AppConstants.SEED_DATABASE_QUESTIONS), type); return saveQuestionList(questionList); } return Observable.just(false); } }); }
final GsonBuilder builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); final Gson gson = builder.create();
public String toJson() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .create(); return gson.toJson(this); }
public String toS() { final Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .create(); return gson.toJson(this); }
public static String getJsonWithExposeFromObject(Object object, Type type) { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .create(); return gson.toJson(object, type); }
public String toS() { Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .registerTypeAdapter(Date.class, new DateTypeAdapter()) .serializeSpecialFloatingPointValues() .create(); return gson.toJson(this); }
public static Treatments fromJSON(String json) { try { return new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(json, Treatments.class); } catch (Exception e) { Log.d(TAG, "Got exception parsing treatment json: " + e.toString()); Home.toaststatic("Error on treatment, probably decryption key mismatch"); return null; } }
public static RollCall fromJson(String json) { final Gson gson = new GsonBuilder() .excludeFieldsWithoutExposeAnnotation() .create(); try { return gson.fromJson(json, RollCall.class); } catch (Exception e) { UserError.Log.e(TAG, "Got exception processing fromJson() " + e); UserError.Log.e(TAG, "json = " + json); return null; } }
private void initBuilder() { builder = new GsonBuilder().setPrettyPrinting(). excludeFieldsWithoutExposeAnnotation(); builder.registerTypeAdapter(OpType.class, new OpType.JsonSerDer()); builder.registerTypeAdapter(Expr.class, new Expr.JsonSerDer()); builder.registerTypeAdapter(PartitionMethodDescExpr.class, new PartitionMethodDescExpr.JsonSerDer()); }