X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.data%2Fscl%2FData%2FJson.scl;h=268b9732a3e17db930708696f2d913c2a50b38a2;hb=refs%2Fchanges%2F80%2F4380%2F1;hp=2190287fcf7560d9f637e20e5600c6ef9805bcff;hpb=66b0fd2ee69d84d3107f109679b6fd1866f8f3fc;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.data/scl/Data/Json.scl b/bundles/org.simantics.scl.data/scl/Data/Json.scl index 2190287fc..268b9732a 100644 --- a/bundles/org.simantics.scl.data/scl/Data/Json.scl +++ b/bundles/org.simantics.scl.data/scl/Data/Json.scl @@ -174,6 +174,7 @@ instance Json Double where readJson = getDoubleValue toJson = JsonDouble fromJson (JsonDouble value) = value + fromJson (JsonLong value) = Java.l2d value instance Json Float where writeJson = writeNumberFloat @@ -308,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) +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