Back to project page on-the-hook.
The source code is released under:
MIT License
If you think the Android project on-the-hook listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.yoandinkov.onthehook.crypt; //from w w w .jav a 2 s . co m import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.yoandinkov.onthehook.models.FishButton; import com.yoandinkov.onthehook.models.FishSpecies; public final class JsonConverter { public static String toJson(Object currentObject) { String result = ""; Gson gson = new Gson(); result = gson.toJson(currentObject); return result; } public static <T> T fromJson(String json, Class<T> type) { Gson gson = new Gson(); T deserializedObject = gson.fromJson(json, type); return deserializedObject; } public static List<FishButton> fromJsonToFishModel(String json) { Gson gson = new Gson(); Type type = new TypeToken<ArrayList<FishButton>>(){}.getType(); List<FishButton> result = gson.fromJson(json, type); return result; } public static List<FishSpecies> fromJsonToFishSpecies(String json) { Gson gson = new Gson(); Type type = new TypeToken<ArrayList<FishSpecies>>(){}.getType(); List<FishSpecies> result = gson.fromJson(json, type); return result; } }