[Haskell-beginners] Parse Json tweets using Aeson

Michael Alan Dorman mdorman at ironicdesign.com
Fri Sep 19 08:40:55 UTC 2014


Tushar Jarhad <tjarhad at gmail.com> writes:
> let mm = decode input :: Maybe Tweet

You have told the program you expect one tweet---anything else is, by
definition, an error. The program takes you at your word.

So if you want it to parse multiple tweets, tell it that you expect a
*list* of tweets.

> let mm = decode input :: Maybe [Tweet]

Or are you saying that your file simply has multiple tweets appended one
after another?  If so, that file does not represent a valid JSON
structure.

I feel sure there's a way to run the parse incrementally---taking a
complete data structure at a time---but I don't know it offhand.

Mike.


More information about the Beginners mailing list