std.json / nested key/value access?

Steven Schveighoffer schveiguy at gmail.com
Fri Nov 15 17:23:38 UTC 2019


On 11/15/19 12:05 PM, Robert M. Münch wrote:
> JSONValue j = parseJSON(json_string).object;
> 
>   writeln(j);                             // works
>   writeln(j["a"]);                     // works
>   writeln(j["a"].object["b"]);     // bombs

auto json_string = `{"a": {"b": 1}}`;

Results with your code as:

{"a":{"b":1}}
{"b":1}
1

Maybe your "a" value is not an object?

-Steve


More information about the Digitalmars-d-learn mailing list