Skip to content

parseJSONStream() requires ForwardRanges #31

@ylegall

Description

@ylegall

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions