]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Support fox six component Json array 16/3916/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 2 Mar 2020 14:02:36 +0000 (16:02 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 2 Mar 2020 14:17:35 +0000 (14:17 +0000)
gitlab #489

Change-Id: I01617086a1abab7a8400fe2b14456bce2647d22e
(cherry picked from commit 3bfc832da98007484d90add605f5fc0fb056f676)

bundles/org.simantics.scl.data/scl/Data/Json.scl

index cacffb01acc806a48d284f220afc8e874c8b8a65..268b9732a3e17db930708696f2d913c2a50b38a2 100644 (file)
@@ -309,6 +309,30 @@ instance (Json a, Json b, Json c, Json d, Json e) => Json (a, b, c, d, e) where
     toJson (a, b, c, d, e) = JsonArray [toJson a, toJson b, toJson c, toJson d, toJson e]
     fromJson (JsonArray [a, b, c, d, e]) = (fromJson a, fromJson b, fromJson c, fromJson d, fromJson e)        
 
     toJson (a, b, c, d, e) = JsonArray [toJson a, toJson b, toJson c, toJson d, toJson e]
     fromJson (JsonArray [a, b, c, d, e]) = (fromJson a, fromJson b, fromJson c, fromJson d, fromJson e)        
 
+instance (Json a, Json b, Json c, Json d, Json e, Json f) => Json (a, b, c, d, e, f) where
+    writeJson g (a, b, c, d, e, f) = do
+        writeStartArray g
+        writeJson g a
+        writeJson g b
+        writeJson g c
+        writeJson g d
+        writeJson g e
+        writeJson g f
+        writeEndArray g
+    readJson p = (a, b, c, d, e, f)
+      where
+        assertStartArray p
+        a = readNextJson p
+        b = readNextJson p
+        c = readNextJson p
+        d = readNextJson p
+        e = readNextJson p
+        f = readNextJson p
+        assertEndArray p
+    toJson (a, b, c, d, e, f) = JsonArray [toJson a, toJson b, toJson c, toJson d, toJson e, toJson f]
+    fromJson (JsonArray [a, b, c, d, e, f]) = (fromJson a, fromJson b, fromJson c, fromJson d, fromJson e, fromJson f)  
+
+
 data Json =
     JsonString String
   | JsonDouble Double
 data Json =
     JsonString String
   | JsonDouble Double