-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add value and decoded types and typedocs. #129
Conversation
Unfortunately using the |
Oh I see. But do you think it would be a reasonable assumption to make that normally hardly anyone will implement the encoder protocol for tuples? I don't know, maybe in 1% of all cases someone might want to, but in those cases they probably need to bring the data into an encodable shape anyway before they pass it to In any case, what do you think about restricting the output type of the decode function? Looks good to me as far as I can see. PS: I made some additional commits to improve things. |
By the way, the |
d9fb885
to
89a25f5
Compare
Hey @michalmuskala, I changed the code so that |
89a25f5
to
e28cb34
Compare
8061e9b
to
e79fcc4
Compare
e79fcc4
to
e70764e
Compare
e70764e
to
3d38761
Compare
* Moved the plain JSON types to the top. * Added type `str` to have a complete set of plain JSON types. * Refer to options either as encoder or decoder options. * Renamed some types to include a clarifying enc_/dec_ prefix.
3d38761
to
978b27b
Compare
Since there hasn't been any activity on this PR for a while, I'll close it for now. Feel free to use any changes in the future if they're helpful. |
Hi!
I'd like to propose adding two types. Namely
value
anddecoded
. I sometimes noticed that it would be great to have a JSON value type handy, when I was dealing with JSON data. I'm sure others would benefit as well when they can refer to a canonical type from the most popular JSON Elixir library itself (e.g.@spec f(Jason.value()) :: Jason.value()
).I gave the input parameters the
decoded
type so that dialyzer may catch instances where developers unknowingly pass a tuple to the encode functions. But I'm not sure if that really helps or if it will be more of a hindrance.I distinguish the
value
type from thedecoded
type, which can have any kind of map keys, so that we can have a stricter and more basic type when we're dealing with JSON data. 👍PS: You'll notice I changed
String.t()
tobinary
. It's a matter of preference to me and we can change it back toString.t()
of course.