URI support (#59)

This commit is contained in:
Patrick Stevens
2024-01-03 19:47:59 +00:00
committed by GitHub
parent 7b3bd32323
commit ad2eeaaa4f
7 changed files with 100 additions and 0 deletions

View File

@@ -944,3 +944,27 @@ module Sessions =
Summary = Summary
Visits = Visits
}
namespace PureGym
/// Module containing JSON parsing methods for the UriThing type
[<RequireQualifiedAccess>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
module UriThing =
/// Parse from a JSON node.
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : UriThing =
let SomeUri =
(match node.["someUri"] with
| null ->
raise (
System.Collections.Generic.KeyNotFoundException (
sprintf "Required key '%s' not found on JSON object" ("someUri")
)
)
| v -> v)
.AsValue()
.GetValue<string> ()
|> System.Uri
{
SomeUri = SomeUri
}