Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for FSharp.Json serialization library #109

Open
ghost opened this issue Dec 1, 2022 · 1 comment
Open

Add support for FSharp.Json serialization library #109

ghost opened this issue Dec 1, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 1, 2022

It would be nice to have support for F# FSharp.Json library to the already existing Thoth, Newtonsoft and SystemTextJson.

Will try implementing that for my local project for now, if it works -> will create a PR in this repo.

Any suggestions on impoving the code will be highly appreciated. 🙂

@ghost
Copy link
Author

ghost commented Dec 1, 2022

@dbrattli could you please help with understanding next things:?

        // json handler w/ FSharp.Json library
        let json<'TResult> (options: JsonConfig) (source: HttpHandler<HttpContent>): HttpHandler<'TResult> =
            let parser (stream: Stream) =
               use sr = new StreamReader(stream)
               // `ReadToEnd` can throw OOM exception. What is the best way to handle it in Oryx?
               let textJson = sr.ReadToEnd()
               Json.deserializeEx<'TResult> options textJson

            parse parser source
  1. What is the best way to handle OOM exception for StreamReader.ReadToEnd()? I have only seen one for Thoth, but I don't know if it will be an OK to return Result wrapped model
match ret with
                | Ok result -> return result
                | Error error -> return raise (JsonDecodeException)
  1. What is the purpose of JsonPushStreamContent and do I need to implement that as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants