From 167fae8bcaa14d8e24055f60ac031b13d8b47199 Mon Sep 17 00:00:00 2001 From: Kevin F Date: Mon, 15 Jan 2024 13:11:21 +0100 Subject: [PATCH] add json functions for better function names in js :sparkles: --- src/ISA/ISA.Json/ArcTypes/ArcAssay.fs | 9 +++++++++ src/ISA/ISA.Json/ArcTypes/ArcInvestigation.fs | 9 +++++++++ src/ISA/ISA.Json/ArcTypes/ArcStudy.fs | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/src/ISA/ISA.Json/ArcTypes/ArcAssay.fs b/src/ISA/ISA.Json/ArcTypes/ArcAssay.fs index 09239920..e8e29e2b 100644 --- a/src/ISA/ISA.Json/ArcTypes/ArcAssay.fs +++ b/src/ISA/ISA.Json/ArcTypes/ArcAssay.fs @@ -82,6 +82,15 @@ module ArcAssay = Assay.encoder (ConverterOptions()) (a.ToAssay()) |> Encode.toString 2 + let toArcJsonString (a:ArcAssay) : string = + let spaces = 0 + Encode.toString spaces (encoder a) + + let fromArcJsonString (jsonString: string) = + match Decode.fromString decoder jsonString with + | Ok a -> a + | Error e -> failwithf "Error. Unable to parse json string to ArcAssay: %s" e + [] module ArcAssayExtensions = diff --git a/src/ISA/ISA.Json/ArcTypes/ArcInvestigation.fs b/src/ISA/ISA.Json/ArcTypes/ArcInvestigation.fs index 1aba93f7..7430282a 100644 --- a/src/ISA/ISA.Json/ArcTypes/ArcInvestigation.fs +++ b/src/ISA/ISA.Json/ArcTypes/ArcInvestigation.fs @@ -73,6 +73,15 @@ module ArcInvestigation = Investigation.encoder (ConverterOptions()) (a.ToInvestigation()) |> Encode.toString 2 + let toArcJsonString (a:ArcInvestigation) : string = + let spaces = 0 + Encode.toString spaces (encoder a) + + let fromArcJsonString (jsonString: string) = + match Decode.fromString decoder jsonString with + | Ok a -> a + | Error e -> failwithf "Error. Unable to parse json string to ArcInvestigation: %s" e + [] module ArcInvestigationExtensions = diff --git a/src/ISA/ISA.Json/ArcTypes/ArcStudy.fs b/src/ISA/ISA.Json/ArcTypes/ArcStudy.fs index a9f43fdc..32c65502 100644 --- a/src/ISA/ISA.Json/ArcTypes/ArcStudy.fs +++ b/src/ISA/ISA.Json/ArcTypes/ArcStudy.fs @@ -67,6 +67,15 @@ module ArcStudy = Study.encoder (ConverterOptions()) (a.ToStudy(assays)) |> Encode.toString 2 + let toArcJsonString (a:ArcStudy) : string = + let spaces = 0 + Encode.toString spaces (encoder a) + + let fromArcJsonString (jsonString: string) = + match Decode.fromString decoder jsonString with + | Ok a -> a + | Error e -> failwithf "Error. Unable to parse json string to ArcStudy: %s" e + [] module ArcStudyExtensions =