You can if you like apply aeson/attoparsec parsers directly to a 'streaming
bytestring'.
import Streaming
import qualified Data.ByteString.Streaming.Char8 as Q
import qualified Data.ByteString.Streaming.Aeson as Aeson
import Data.Aeson
import qualified Data.Attoparsec.ByteString.Streaming as A
I can write things like this (note there is the obvious IsString instance
for `ByteString m r`):
>>> (a,b) <- A.parse json' $ void $ Q.splitAt 27
"{\"a\":[1,2],\"b\":[3,4] } xxxxxxxxxxxxxxxxx"
>>> a
Left (Object (fromList [("a",Array [Number 1.0,Number 2.0]),("b",Array
[Number 3.0,Number 4.0])]))
>>> Q.length b
5 :> ()
Obviously one should take account of where in general the bytes one is not
reading were supposed to be coming from and similar questions.
--
You received this message because you are subscribed to the Google Groups
"Haskell Pipes" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].