More on this after some more investigation, and SO feedback: Problem: How to encode and decode a JSON object in streaming fashion where we need some information from JSON body before handling rest of JSON body - I have an object of type (Text,Lazy ByteString) where text has metadata (e.g., say filepath to write to) that allows us to handle bytestring (e.g., an image that is streamed to a consumer/sink based on metadata information).
The text metadata needs to be ordered before the bytestring so it can be parsed before we start parsing bytestring in streaming fashion. So, I picked the tuple since it can be encoded as an ordered JSON array (which aeson does as well in deriveJSON for tuple types). Another approach is probably concatenated json or newline <https://en.wikipedia.org/wiki/JSON_Streaming#Line_delimited_JSON>. Now, what I am trying to figure out is what is the best way to solve this - should I use a custom parser with aeson ToJSON/FromJSON instance, or a pipe parse, pipe aeson or something else? What would a good solution look like to this problem? I just need a JSON parser that can parse the metadata, and then continue streaming parse on bytestring based on metadata information - that way, I could pipe it between producer and consumer (so, if the parse is incomplete, we could undo the write). Since I haven't used pipes before, I am unsure how to proceed here, and so, will very much appreciate pointers. Psuedo-code or toy examples will be very helpful. On Saturday, May 28, 2016 at 8:20:02 AM UTC-4, Sal wrote: > > Hello, > > I just posted this pipes related question at stackoverflow: > http://stackoverflow.com/questions/37498848/decoding-json-stream-where-some-values-are-needed-before-others > > If any one has pointers on this, will very much appreciate it. I control > the Javascript client that sends the JSON if this makes it easier to solve > the problem. > -- 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 haskell-pipes+unsubscr...@googlegroups.com. To post to this group, send email to haskell-pipes@googlegroups.com.