fsprojects / Fleece

Json mapper for F#
http://fsprojects.github.io/Fleece
Apache License 2.0
199 stars 31 forks source link

Question: is this library usable from C#? #69

Open knocte opened 4 years ago

gusty commented 4 years ago

I personally never tried, nor considered that possibility.

It would be interesting to hear what other authors and users say about this.

Anyway, for sure all the SRTP functionality won't work from C#, but passing explicitly the encoder / decoder combinator should work and signatures are not that specific to F#, except the Result type.

Advanced use of codecs, avoiding SRTPs by passing explicitly the codec combinator should work in theory from C# but the signatures would be too complicated to handle from C# I think.

See the section https://github.com/mausch/Fleece#combinators there are some examples that might be possible to code from C#

Regarding the former (decoder and encoder combinators) they are readyo use, stuff like: JsonDecode.array or JsonEncode.dictionary, see in the source modules JsonEncode and JsonDecode for more information.

Don't forget give us feedback !

knocte commented 4 years ago

Thanks; but looking at the docs more deeply I'm not sure Fleece meets my needs, as I was looking for something more "automatic" that let me not need to hardcode strings (still with no reflection usage) e.g. like the auto-coders of Thoth https://thoth-org.github.io/Thoth.Json/#Auto-coders , is there anything like this in Fleece?

wallymathieu commented 4 years ago

I think that sounds like different use case than what Fleece is supposed to solve?

gusty commented 4 years ago

Well, I think those auto-coders do use reflection, or maybe another technique but also at run-time.

Fleece is automatic for known types, for the rest you have to describe (with functions) what do you want. That's why it's a Json mapper.

We might consider adding auto-coders at some stage, provided that there's always a way to opt-out from them so we don't lose compile-time guarantees.