<html><head></head><body><div>You could drop down to the attoparsec layer, but instead of messing with IResults, use it to make another parser that will parse all the objects in the file.</div><div><br></div><div>E.g. json `sepBy` skipSpace :: Parser [Value]</div><div><br></div><div>sepBy and skipSpace both taken from Data.Attoparsec.Text</div><div><br></div><div>On Sun, 2016-05-29 at 13:09 -0400, Ryan Newton wrote:</div><blockquote type="cite"><div dir="ltr">As someone who spent many years putting data in S-expression format, it seems natural to me to write multiple S-expressions (or JSON objects) to a file, and expect a reader to be able to read them back one at a time.<div><br></div><div>This seems comparatively uncommon in the JSON world. Accordingly, it looks like the most popular JSON parsing lib, Aeson, doesn't directly provide this functionality. Functions like decode just return a "Maybe a", not the left-over input, meaning that you would need to somehow split up your multi-object file before attempting to parse, which is annoying and error prone.</div><div><br></div><div>It looks like maybe you can get Aeson to do what I want by dropping down to the attoparsec layer and messing with IResult.</div><div><br></div><div>But is there a better way to do this? Would this be a good convenience routine to add to aeson in a PR? I.e. would anyone else use this?</div><div><br></div><div>Thanks,</div><div> -Ryan</div><div><br></div><div><br></div></div>
<pre>_______________________________________________
Haskell-Cafe mailing list
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
</pre></blockquote></body></html>