thoth-org / Thoth.Json

Library for working with JSON in a type safe manner, this libs is targeting Fable

Home Page:https://thoth-org.github.io/Thoth.Json/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto coders for int64 with a UoM in 5.1.0

kerams opened this issue · comments

Hello,

My model uses int64 with a unit of measure. In 5.0.0 I used Encode.Auto.generateEncoderCached<'a> () to create serializers with no problems. Seeing that implicit support for longs has been removed in 5.1.0, I tried using Encode.Auto.generateEncoderCached<'a> (extra = Extra.withInt64 Extra.empty), but I still get Error: Cannot generate auto encoder for Microsoft.FSharp.Core.int64`1. Please pass an extra encoder. I assume the problem is the fact that Thoth does not see System.Int64. Is this addressable within the library do I have to create custom coders?

Hello @kerams,

this issue seems related to #74.

In the issue I linked the problem was that Fable was not generating the correct name for UoM when using reflection.

According to the discussion in the issue it seems to have been fixed in Fable version 3.1.1. Can you please give it a try?

If you are still using Fable 2 and not ready to upgrade to Fable 3, you can workaround the Fable bug by manually providing the name of the type for reflection. See #74 (comment)

I've updated from 3.1.0 to 3.1.1 and it did indeed solve the issue. Should've checked other issues first :). Thanks a lot.

Thank you for confirming :)