Tango JSON Parser: Accessing the members
Benji Smith
dlanguage at benjismith.net
Sat Aug 16 16:31:20 PDT 2008
I've been trying out the new tango JSON parser, and the functionality
for actually parsing the string is very easy to invoke. But I can't
figure out, for the life of me, how to read the individual children of
the resultant object hierarchy.
Here's what I've got:
module mymodule;
import tango.text.json.Json;
void main() {
char[] json = `{"t": true}`;
auto parser = new Json!(char);
// "Error: identifier 'JsonValue' is not defined"
JsonValue* jsonValue = p.parse(json);
// "Error: identifier 'JsonObject' is not defined"
JsonObject jsonObject = p.parse(json).toObject();
// "Error: identifier 'Composite' is not defined"
Composite composite = p.parse(json).toObject();
}
I'm sure I'm missing something from my 'import' declarations, but I've
tried adding "tango.text.json.JsonValue" or
"tango.text.json.Json.JsonValue" or "tango.text.json.Json.Composite" and
the compiler has not been happy with any of those (each of which is a
struct or an alias defined within the Json class).
Has anyone else tinkered with the JSON stuff yet? Any ideas?
Thanks!
--benji
More information about the Digitalmars-d-learn
mailing list