I have parsed a json list and it comes out with each element like:
{struct,
[
{<<"name">>, "<<a name>>"},
{<<"id">>, "<<an id>>""}
]
}
I would like to specify this as a type, but I get an error with the following, presumably because I’m using two elements in the list definition:
-type user_data() :: {struct, [{Name_key::Binary, Name_value::Binary},{ID_key::Binary, ID_value::Binary}]}.
Is there any way to do what I’m trying to do?
You can do
meaning a list every element of which is either a
{Name_key::binary(), Name_value::binary()}or an{ID_key::binary(), ID_value::binary()}. This isn’t quite what you want but may be good enough.