Last active
August 29, 2015 14:07
-
-
Save nakaji-dayo/d035912adad6911a8b36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rr = case decode "[{\"key\":\"yahoo\", \"count\": 5},{\"key\":\"google\"}]" of | |
| Nothing -> fail "decode error" | |
| Just v -> (parse parser v) :: Result String | |
| where parser = parseJSON >=> withArray "array" (.!! 0) >=> withObject "object" (.: "key") | |
| (.!!) :: (FromJSON a) => Array -> Int -> Parser a | |
| arr .!! i | |
| | V.length arr >= i = parseJSON $ arr V.! i | |
| | otherwise = fail "hogeeee" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment