The line dash of singlebit wires changes according to their value
[Mograsim.git] / plugins / net.mograsim.logic.model / src / net / mograsim / logic / model / util / JsonHandler.java
index 950b953..4c49104 100644 (file)
@@ -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> T readJson(String path, Class<T> type) throws IOException
        {
@@ -42,6 +45,11 @@ public class JsonHandler
                return parser.fromJson(src, type);
        }
 
+       public static <T> T fromJson(JsonElement json, Class<T> type)
+       {
+               return parser.fromJson(json, type);
+       }
+
        public static <T> T fromJsonTree(JsonElement src, Class<T> type)
        {
                return parser.fromJson(src, type);