elm-community / json-extra

Convenience functions for working with Json.
http://package.elm-lang.org/packages/elm-community/json-extra/latest
MIT License
37 stars 16 forks source link

Add `doubleEncoded` decoder #12

Closed mltsy closed 7 years ago

mltsy commented 7 years ago

This decoder decodes a string field that contains a JSON-encoded string.

As outlined by @jamesmacaulay for me (thanks!) :+1:

We could alternately call this json or jsonString to indicate that the field contains JSON, which would be more consistent with other built-in decoders (string, int, list, etc.), but doubleEncoded seems nicely explicit in a context where everything is supposed to be JSON. I'm not sure which is clearer.

Also, I'm not sure if I got the documentation format right (I'm not familiar with it, so I just copied the format I saw on other methods)

zwilias commented 7 years ago

I don't think json and jsonString are very good names for this - int returns decodes into an Int, string decodes into a String, json decodes json into something else entirely. Perhaps doubleEncoded is the better choice here, indeed.

I'll merge this and add some doc-tests :)

mltsy commented 7 years ago

Ah, sure, that makes sense from that perspective. I guess list and dict also decode into the corresponding types, rather than naming a kind of data in the json context (such as object or array). :+1: