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

Clarify docs for the Json.Decode (:=) operator. #341

Merged
merged 1 commit into from Nov 28, 2015

Conversation

Projects
None yet
3 participants
@rgrempel
Contributor

rgrempel commented Aug 10, 2015

The purpose of this change would be to clarify the documentation for the Json.Decode (:=) operator.

It seems to me that the current documentation ("Decode an object if it has a certain field"), could be misleading to some people. Consider an example JSON object, e.g.

{
    "username": "bob",
    "password": "secret"
}

Then, consider the work done by something like:

"username" := string

The 'object' which this decodes is "bob". But, "bob" does not have the field 'username' -- it is the field 'username'. To the extent that the whole object is decoded -- that is, the object which 'has' the field 'username' -- the whole object is decoded by something like Json.Decode.object2.

Also, I think that it would be helpful to specifically mention the word "fail", rather than simply leave it at "if". This lines up with the use of the word "fail" in the rest of the docs -- thus, pointing the user to what can be done to deal with failure.

@fbonetti

This comment has been minimized.

Show comment
Hide comment
@fbonetti

fbonetti commented Sep 19, 2015

👍

evancz pushed a commit that referenced this pull request Nov 28, 2015

Merge pull request #341 from rgrempel/clarify-JSON-Decode-docs
Clarify docs for the Json.Decode (:=) operator.

@evancz evancz merged commit 9e01233 into elm:master Nov 28, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@rgrempel rgrempel deleted the rgrempel:clarify-JSON-Decode-docs branch Nov 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment