List of usage examples for com.google.gson Gson Gson
public Gson()
From source file:app.witness.com.myapplication.dagger.ApplicationModule.java
License:Open Source License
@Singleton @Provides public Gson provideGson() { return new Gson(); }
From source file:app.witness.com.myapplication.dagger.GsonModule.java
License:Open Source License
@Provides public Gson provideGson() { return new Gson(); }
From source file:app24.feedbook.hk.utils.Utils.java
License:Apache License
public void setLatestFeedPreferences(Activity activity, LatestFeedsModel model) { SharedPreferences sharedPref = activity .getSharedPreferences(activity.getResources().getString(R.string.app_name), Context.MODE_PRIVATE); SharedPreferences.Editor prefsEditor = sharedPref.edit(); Gson gson = new Gson(); String json = gson.toJson(model); prefsEditor.putString(Constants.LATEST_FEED_MODEL, json); prefsEditor.commit();// w ww . ja v a 2 s.c o m Log.e("Saved Model", "LatestModelSaved "); }
From source file:app24.feedbook.hk.utils.Utils.java
License:Apache License
public LatestFeedsModel getLatestFeedPreferences(Activity activity) { SharedPreferences sharedPref = activity .getSharedPreferences(activity.getResources().getString(R.string.app_name), Context.MODE_PRIVATE); Gson gson = new Gson(); String json = sharedPref.getString(Constants.LATEST_FEED_MODEL, ""); LatestFeedsModel feedsModel = gson.fromJson(json, LatestFeedsModel.class); return feedsModel; }
From source file:app24.feedbook.hk.utils.Utils.java
License:Apache License
public void setUserFeedPreferences(Activity activity, UserFeedModel model) { SharedPreferences sharedPref = activity .getSharedPreferences(activity.getResources().getString(R.string.app_name), Context.MODE_PRIVATE); SharedPreferences.Editor prefsEditor = sharedPref.edit(); Gson gson = new Gson(); String json = gson.toJson(model); prefsEditor.putString(Constants.LATEST_FEED_MODEL, json); prefsEditor.commit();//from w ww . ja v a 2 s . co m Log.e("Saved Model", "LatestModelSaved "); }
From source file:app24.feedbook.hk.utils.Utils.java
License:Apache License
public UserFeedModel getUserFeedPreferences(Activity activity) { SharedPreferences sharedPref = activity .getSharedPreferences(activity.getResources().getString(R.string.app_name), Context.MODE_PRIVATE); Gson gson = new Gson(); String json = sharedPref.getString(Constants.LATEST_FEED_MODEL, ""); UserFeedModel feedsModel = gson.fromJson(json, UserFeedModel.class); return feedsModel; }
From source file:appbox.ideastracker.database.TinyDB.java
License:Apache License
public Object getObject(String key, Class<?> classOfT) { String json = getString(key); Object value = new Gson().fromJson(json, classOfT); if (value == null) throw new NullPointerException(); return value; }
From source file:appeng.services.version.github.ReleaseFetcher.java
License:Open Source License
public FormattedRelease get() { final Gson gson = new Gson(); final Type type = new ReleasesTypeToken().getType(); try {//from ww w . java2s. c om final URL releasesURL = new URL(GITHUB_RELEASES_URL); final String rawReleases = this.getRawReleases(releasesURL); this.config.updateLastCheck(); final List<Release> releases = gson.fromJson(rawReleases, type); final FormattedRelease latestFitRelease = this.getLatestFitRelease(releases); return latestFitRelease; } catch (final VersionCheckerException e) { AELog.debug(e); } catch (final MalformedURLException e) { AELog.debug(e); } catch (final IOException e) { AELog.debug(e); } return EXCEPTIONAL_RELEASE; }
From source file:Application.Services.ServicoSX.java
@POST @Path("/calcularValores") @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED }) @Produces(MediaType.APPLICATION_JSON)/*w ww . j a va 2 s. c o m*/ public RetornoJsonDTO calcularValores(String lista, String problema) { try { Util u = new Util(); List<List<String>> listal = new ArrayList<List<String>>(); JSONObject request = new JSONObject(lista); JSONArray arr = request.getJSONArray("vetor"); Gson gson = new Gson(); TipoProblemaDTO tp = gson.fromJson(request.get("problema").toString(), TipoProblemaDTO.class); for (int i = 0; i < arr.length(); i++) { listal.add(u.JsonArrayStringToList(arr.getJSONArray(i))); } Simplex s = new Simplex(); Problema p = new Problema(listal, tp.getId()); s.executarSimplex(p); List result = s.imprimeResultado(); RetornoJsonDTO retornojson = new RetornoJsonDTO(); retornojson.setError(false); retornojson.setData(result); return retornojson; } catch (Exception e) { RetornoJsonDTO retornojson = new RetornoJsonDTO(); retornojson.setError(true); retornojson.setErrorMessage(e.getMessage()); return retornojson; } }
From source file:AppUemWS.AppReservaUemWS.java
@GET @Produces(MediaType.APPLICATION_JSON)/* w w w . j a va2s . c o m*/ @Path("/solicitarDataAtual") public String solicitarDataAtual() { Gson g = new Gson(); DateFormat dtIso = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); return g.toJson(dtIso.format(calendar.getTime())); }