xyncro / chiron

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

Json.deserializeWith support? #66

Open ninjarobot opened 8 years ago

ninjarobot commented 8 years ago

I have some types that are out of my control and I can add a custom SomeTypeToJson and SomeTypeFromJson functions. Serialization works fine using Json.serializeWith but I've looked through the source and tests and just don't see how to use my custom deserializer. A Json.deserializeWith function would make sense, but I really don't see anything like that or any other way to use it so I think I'm just missing it. Can you point me in the right direction, please?

kolektiv commented 8 years ago

Yes you're right, the serializeWith functions were contributions, but I've not got round to adding the equivalent deserialization logic. It would definitely be a good thing to have! Sadly you're not missing it. It's probably not a big change, but I'm probably not able to add it in the next couple of weeks, as I've got a lot of commitments on other things. I'll likely get to it in the next couple of weeks though now you've raised it.

If you want to have a stab at adding the appropriate functions I'll do my best to give useful feedback and answer questions, otherwise I'll get to it ASAP!

haf commented 7 years ago

Being able to extract the serialisation logic away from the types would be a great feature; because having it all intermingled becomes very distracting when your domains get larger.

Arrow7000 commented 6 years ago

I've come across this issue after googling Json.deserializeWith. I don't want to pollute my record types with serialization logic, which is why I found the Json.serializeWith function really helpful. It would be really helpful if there was an equivalent for deserialization!

haf commented 6 years ago

@neoeinstein Has his chiron-7 branch with this in it.