Lazily parse a JSON text file using stdx.data.json?
David Gileadi
gileadisNOSPM at gmail.com
Sun Dec 17 04:34:22 UTC 2017
I'm a longtime fan of dlang, but haven't had a chance to do much
in-depth dlang programming, and especially not range programming. Today
I thought I'd use stdx.data.json to read from a text file. Since it's a
somewhat large file, I thought I'd create a text range from the file and
parse it that way. stdx.data.json has a great interface for lazily
parsing text into JSON values, so all I had to do was turn a text file
into a lazy range of UTF-8 chars that stdx.data.json's lexer could use.
(In my best Clarkson voice:) How hard could it be?
Several hours later, I've finally given up and am just reading the whole
file into a string. There may be a magic incantation I could use to make
it work, but I can't find it, and frankly I can't see why I should need
an incantation in the first place. It really ought to just be a method
of std.stdio.File.
Apparently some of the complexity is caused by autodecoding (e.g. joiner
returns a range of dchar from char ranges), and some of the fault may be
in stdx.data.json, but either way I'm surprised that I couldn't do it.
This is the kind of thing I expected to be ground level stuff.
More information about the Digitalmars-d
mailing list