json-stream icon indicating copy to clipboard operation
json-stream copied to clipboard

Return unparsed numbers/scalar data?

Open dylex opened this issue 3 years ago • 1 comments

As a generalization or similar case of #22, I have cases where it would be nice to avoid (or delay) parsing of numeric data, with something like byteStringNumber :: Parser ByteString that "parsed" numbers (or even any scalar data would be fine) with just their original encoding. Looking at the code it seems the integer parsing at least happens in the C code very early, so I understand this is not straight-forward in the current implementation.

As a more general case, I'm looking to use this to do efficient JSON transformations (of large streaming ES search results), where you do something like "hits" .: "hits" .: arrayOf ("fields" .: rawByteStringObject) and get the raw ByteString (or tokenstream would be fine too) that you could then put back into a new json document (like with unsafeToEncoding) without having to parse it, like how ignore works but capturing the input somehow.

(Sorry for all the issues, and thanks for the library, just starting to use it.)

dylex avatar May 20 '22 21:05 dylex

Can you make your own type that gets decoded at all?

Because I want to start checking the values I'm being handed in the JSON before allowing them into a constructor, I created my own converter for FromJSON.

https://github.com/rickprice/google-location-history-converter

In src/Data/Location/Model.hs

Perhaps you can do it using an "object" parser?

Anyway, if you wish to talk, my email is [email protected]

I'm also new to Haskell and json-stream, but I do have it working.

rickprice avatar Jan 23 '24 21:01 rickprice