Skip to content

[FR] Decode.uri and Encode.uri #222

@laurentpayot

Description

@laurentpayot

Hi, I could not find Decode.uri (or equivalent) that would be the same as Decode.string |> Decode.map System.Uri.

Decoding URIs is very common so I had to write the following extension to add the very handy Decode.uri and Encode.uri features:

[<AutoOpen>]
module ThothExtensions

open System
open Thoth.Json.Core


module Thoth =
    module Json =
        module Core =
            module Decode =
                let uri: Decoder<Uri> = Decode.string |> Decode.map Uri

            module Encode =
                let uri: Encoder<Uri> = _.ToString() >> Encode.string

Just like the super-useful Decode.guid and Encode.guid, would it be possible to have Decode.uri and Encode.uri directly out of the box of Thoth.Json?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions