xyncro / chiron

JSON for F#
https://xyncro.tech/chiron
MIT License
175 stars 41 forks source link

Add custom read write functions #44

Closed neoeinstein closed 8 years ago

neoeinstein commented 8 years ago

Sometimes there is a need to serialize or deserialize values for types that were not created within the same assembly. Extension methods don't work to add ToJson or FromJson methods to these types. In this PR, I use System.DayOfWeek as the exemplar, but I plan to use it for serializing types from the NodaTime library. The key change here is to expose the Json -> JsonResult<'a> and 'a -> Json shaped holes in the read/write functions.

Let me know what you think.

kolektiv commented 8 years ago

Merged this in via a local pull, etc. Very cool! It'll be in 5.1.0 (#45) very shortly. There's some (currently non-breaking) changes to lens functions in there as well if you're using them - deprecations given though. Thanks for this, it's a very useful and usable change - awesome!