parse json-string - operator overload error
zusta
zusta at mail.bg
Wed Dec 1 00:17:37 PST 2010
Hey guys,
I'm trying to read a JSON-formated file. The parsing of the file seems to be
correct, but I always get the following error:
"Error: no [] operator overload for type JSONValue".
For testing purposes, I also tried the code of
http://www.digitalmars.com/d/archives/digitalmars/D/std.json_API_improvement_
-_Request_for_code_review_117261.html#N117302 without success (same error).
My currently code looks like this:
import std.stdio : writeln;
import std.json;
import std.stream;
import std.conv;
void main(string[] args) {
File f = new File("test.json", FileMode.In);
string content = to!(string)(f.readString(f.available()));
JSONValue t = parseJSON(content);
writeln(t["test"]);
f.close();
}
I hope anyone can help to find out what's wrong with the code above.
More information about the Digitalmars-d-learn
mailing list