pimbrouwers / Falco

A toolkit for building fast and functional-first web applications using F#.
https://www.falcoframework.com
Apache License 2.0
530 stars 38 forks source link

Json Serialization #11

Closed AngelMunoz closed 4 years ago

AngelMunoz commented 4 years ago

Hey, I just discovered Falco and it looks pretty neat! I'll try to give it a run on the following days

I just have a question about JSON serialization/deserialization I saw that you are using the System.Text.Json API's

I believe I tried those previously in another project but ran into exceptions once I tried to deserialize option types as well as Discriminated Unions, with that in mind

Is it safe to just deserialize json?

if not, you might want to consider taking a look at https://github.com/Tarmil/FSharp.SystemTextJson which uses the same API's but with some F# sugar for those mentioned types

pimbrouwers commented 4 years ago

Hi Angel! (Badass name btw!)

Thank you very much for reaching out! I knew this topic would come up at some point and I should likely express my views in JSON more clearly in the documentation.

I included the jsonOut method as a convenience function for those times you need "quick and dirty" JSON output.

I explicitly chose not to include any meaningful JSON handlers or functionality beyond this because there isn't really a commonly accepted way of doing it. Thus, I figured it would be easiest to let people roll their own.

That said, if people were open to a dependency and could agree on a package. I would be more than happy to add full JSON support.

For the time being Ill update that documentation with a section on JSON to reflect my views on the subject.

AngelMunoz commented 4 years ago

Hi Angel! (Badass name btw!)

I'll thank my mother for that 😆

I explicitly chose not to include any meaningful JSON handlers or functionality beyond this because there isn't really a commonly accepted way of doing it. Thus, I figured it would be easiest to let people roll their own.

Yeah I get that 😁

Got it then thanks!

pimbrouwers commented 4 years ago

Documentation added in commit 19730fdff3bca78a464e4876329843c55d3a80f1