rec2json
rec2json copied to clipboard
types do not resolve to simplest type
Hi,
If I define a record like this:
-record( thing ,
{
prop1 :: binary() ,
prop2 :: mylist()
}).
And in an include file I have defined
-type mylist :: [ integer() ].
-export_type ([mylist/0]).
I am finding that rec2json does not reduce mylist() to [integer()] and therefore never processes prop2.
Am I missing something or is this intended behaviour or should the be filed as an enhancement?
Thanks
The short answer is an enhancement should be filed to support local user-defined type. Changing the property to prop2 :: ?MODULE:mylist()
and exporting a mylist/1
function will work as well.
rec2json
does not inspect the shape of user-defined types, nor does it support local user types. When it comes across prop2 :: my list()
it will skip over it completely as it is a localy defined type. For remote types rec2json
will attempt to used a function with the same module and name to encode/decode the value.