jawn icon indicating copy to clipboard operation
jawn copied to clipboard

How to do stream parsing?

Open steinybot opened this issue 8 years ago • 3 comments

I have tried to use the AsyncParser but I couldn't figure out how to get anything out other than a single jsobject as defined by my AST (in this case Play JSON).

Assume I have something like:

{
  "name": "thing"
  "elements": [{
    "key": "a",
    "value": "alice"
  },{
    "key": "b",
    "value": "bob"
  },
  ...
  ]
}

How can I get it so that each call to absorb will return zero or more elements?

steinybot avatar Aug 24 '17 05:08 steinybot

Hi,

I'm facing to the same usecase... I will glad to know how you resolved it :) Regards

gchauvet avatar Dec 04 '17 19:12 gchauvet

@gchauvet I didn't resolve it. To be fair I didn't spend much time looking into it but this was the only thing I wanted so gave up pretty quick.

steinybot avatar Mar 31 '18 09:03 steinybot

I found jawn-fs2, this module provide jawn async parser binding to fs2 stream, which provide a functional abstraction over streaming, also I quickly inspect its code, seems it doesn't require too much work to bind, so I assume it should be relatively easy to bind to other streaming library if you have a prefer.

GreyPlane avatar Feb 19 '24 01:02 GreyPlane