purescript-contrib/purescript-argonaut-codecs

Encode/Decode Natural

f-f opened this issue · 1 comments

f-f commented

Would a PR to implement EncodeJson/DecodeJson for Natural be welcome?

Unfortunately, since Natural is outside of core / contrib we won't bring in the dependency here. If you're using automatic record decoding that's unfortunate, but if you're manually writing encoders / decoders you could decode as an int and then immediately parse as a natural -- something (hand-wavy) like thisS

myField <- note (TypeMismatch "Natural") Natural.parse =<< rec .: "natural_field"