X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Futil%2FJsonHandler.java;h=4c49104b70dca2f6093fcd8d5f681681bf407b96;hb=7908fec28b61e5911bf6523a3c10cd3a31dc95e6;hp=950b95322bd7a82655c174efd436731a6e47532c;hpb=2198fbadd2105c47ff4cd65d434616ae329802a1;p=Mograsim.git diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/util/JsonHandler.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/util/JsonHandler.java index 950b9532..4c49104b 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/util/JsonHandler.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/util/JsonHandler.java @@ -13,9 +13,12 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; +import net.mograsim.logic.core.types.BitVector; + public class JsonHandler { - public final static Gson parser = new GsonBuilder().setPrettyPrinting().create(); + public final static Gson parser = new GsonBuilder().registerTypeAdapter(BitVector.class, new BitVectorAdapter()).setPrettyPrinting() + .create(); public static T readJson(String path, Class type) throws IOException { @@ -42,6 +45,11 @@ public class JsonHandler return parser.fromJson(src, type); } + public static T fromJson(JsonElement json, Class type) + { + return parser.fromJson(json, type); + } + public static T fromJsonTree(JsonElement src, Class type) { return parser.fromJson(src, type);