Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseJSONStream() requires ForwardRanges #31

Open
ylegall opened this issue Sep 17, 2017 · 1 comment
Open

parseJSONStream() requires ForwardRanges #31

ylegall opened this issue Sep 17, 2017 · 1 comment

Comments

@ylegall
Copy link

ylegall commented Sep 17, 2017

The signature of parseJSONStream() constrains the input type to InputRange, but it seems like it actually requires a ForwardRange due to the calls to std.algorithm.skipOver() in lexer.d.

I was trying to call parseJSONStream() on a range of ubyte from a file (without reading the entire file into memory), using the basic approach:

auto fileRange = File("input.json").byChunk(4096).joiner;
auto tokens = parseJSONStream(fileRange);

This fails with a type error:
std_data_json-0.18.2/std_data_json/source/stdx/data/json/lexer.d(341,29): Error: template std.algorithm.searching.skipOver cannot deduce function from argument types !()(Result, string)

Is there better way to do this? Probably at the least, the template constraints for parseJSONStream() should be changed to ForwardRange, but support for InputRanges would allow incremental parsing from a file.

Also, here is a related open forum thread: http://forum.dlang.org/thread/[email protected]

@marcioapm
Copy link

It seems like it also doesn't work well with ubyte input stream, i.e. the result from vibe.d's request/response bodyReader()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants