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

Keys #15

Closed Chadtech closed 6 years ago

Chadtech commented 6 years ago

Here is a function to get the keys of a JSON object. It works just by using the core function keyValuePairs and then discards the values.

We wrote this up this function at my job, where we needed to decode a list of urls, that werent just stored as strings but { < urlType > : String } where the urlType varied and it was the only information we cared about.

zwilias commented 6 years ago

Cool, thanks for clarifying a use-case for this!

Could you do me a favour and restructure the example to be a valid doc-test? The assertion should be last and start with -->. You can run the tests locally - npm i && npm test should set everything up and run stuff.

Generally the examples are

input
    |> someAction
--> expectedResult

-> it would be neat to keep that consistent!

Thanks for you contribution, @Chadtech <3

Chadtech commented 6 years ago

Done! Never used doc test before. Thats cool.

Chadtech commented 6 years ago

Oh shoot Im sorry. My example wasnt even right.

zwilias commented 6 years ago

Eh, it was close enough 😄 Hence, the doc-tests. I'mma merge it, thanks for the contribution @Chadtech!