Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upImprove docs for Json.(En|De)code #243
Conversation
mgold
added some commits
May 11, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
May 27, 2015
Contributor
Rebased on to master and added a second commit fixing Graphic.Input's docs - previous they invoked Signal.Mailbox as a function when it should be Signal.mailbox, lowercase. CI should pass.
|
Rebased on to master and added a second commit fixing Graphic.Input's docs - previous they invoked |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
May 27, 2015
Contributor
Closing and reopening to force CI to rebuild; it seems to be a flaky download.
|
Closing and reopening to force CI to rebuild; it seems to be a flaky download. |
mgold
closed this
May 27, 2015
mgold
reopened this
May 27, 2015
evancz
reviewed
May 27, 2015
src/Json/Decode.elm
| {-| Great for handling optional fields. The following code decodes JSON | ||
| objects that may not have a profession field. | ||
| {-| Extract a Maybe value, wrapping successes with `Just` and turning any | ||
| failure in `Nothing`. Great for handling fields that may be missing or null. The |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
May 27, 2015
Member
This is actually not that great for things that may be null because it actually admits all sorts of errors. A decoder that can be null or something, is different than a decoder that is something or anything. If the given decoder messes up, it'll give Nothing (corresponding to null which it is not) rather than failing.
evancz
May 27, 2015
Member
This is actually not that great for things that may be null because it actually admits all sorts of errors. A decoder that can be null or something, is different than a decoder that is something or anything. If the given decoder messes up, it'll give Nothing (corresponding to null which it is not) rather than failing.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
reviewed
May 27, 2015
| @@ -55,6 +55,8 @@ int = | ||
| Native.Json.identity | ||
| {-| Encode a Float. `Infinity` and `NaN` are encoded as `null`. | ||
| -} |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
May 27, 2015
Contributor
> import Json.Encode as E
> E.encode 0 (E.float (1/0))
"null" : String
> E.encode 0 (E.float (0/0))
"null" : String
Personally I'm fine with this behavior. I like how encoding always succeeds.
mgold
May 27, 2015
Contributor
> import Json.Encode as E
> E.encode 0 (E.float (1/0))
"null" : String
> E.encode 0 (E.float (0/0))
"null" : String
Personally I'm fine with this behavior. I like how encoding always succeeds.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
May 27, 2015
Member
Shouldn't Elm's floats map on to the same floats though? Like, why would NaN not result in Nan? Is that not valid JSON or something?
evancz
May 27, 2015
Member
Shouldn't Elm's floats map on to the same floats though? Like, why would NaN not result in Nan? Is that not valid JSON or something?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
May 27, 2015
Contributor
Numeric values that cannot be represented as sequences of digits (such as Infinity and NaN) are not permitted. [page 9]
$ node
> JSON.stringify(NaN)
'null'
> JSON.stringify(Infinity)
'null'
mgold
May 27, 2015
Contributor
Numeric values that cannot be represented as sequences of digits (such as Infinity and NaN) are not permitted. [page 9]
$ node
> JSON.stringify(NaN)
'null'
> JSON.stringify(Infinity)
'null'
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Thanks! Besides the two comments, this looks really great! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
New commit should address the null issue. |
pushed a commit
that referenced
this pull request
May 27, 2015
evancz
merged commit 5ee7261
into
elm:master
May 27, 2015
1 check passed
mgold
deleted the
mgold:docs-refinements
branch
May 28, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Thanks! |
mgold commentedMay 12, 2015
Improve docs for the Json libraries, most notably
Decode.tuple1Decoder aisHopefully an easy merge - if there's anything odd, please let me know.