Redefined PinUsages; cleaned component JSONs
[Mograsim.git] / plugins / net.mograsim.logic.model / src / net / mograsim / logic / model / util / JsonHandler.java
index 20491ce..7c8e353 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
        {
@@ -39,9 +42,7 @@ public class JsonHandler
 
        public static <T> T fromJson(String src, Class<T> type)
        {
-               // throw away legacy version line
-               String rawJson = src.lines().dropWhile(s -> s.length() == 0 || s.charAt(0) != '{').collect(Collectors.joining());
-               return parser.fromJson(rawJson, type);
+               return parser.fromJson(src, type);
        }
 
        public static <T> T fromJsonTree(JsonElement src, Class<T> type)