Parsing JSON Objects without intermediate ASTs

8 points by abhin4v


tobz619

Oooh that's quite interesting.

It feels a lot like a raw stack allocation with uninitialised fields. Passing a bitset to check that all fields are set is so simple and effective.

I do wonder if this pattern can be generalised through Haskell via some wrapper type and the bitset could be hidden.

I've been trying to implement a similar approach for a web app I've been working to make sure a policy is uploaded by one client by the time another client needs.

Nice to know I wasn't totally insane for trying it out haha :D

morj

Cool approach. Defining the target records with lazy fields is likely unacceptable to the users, but this could likely be saved by first deserializing into a tuple, and then spilling this tuple into the record, code for this being produced by TH or generics; I hope the optimizer will be able to see through the tuple and make the transformation free

This shows that skipping the intermediary repr gives a 3x speedup. I once did a mini-benchmark of aeson vs serde_json, and the difference was 9x. Now it remains to recover the second 3x improvement and we would have officially proven that haskell is the superior of languages