www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - parse json-string - operator overload error

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.
Dec 01 2010