Hi All,

Currently we are testing various json module such as "std.json, std_data_json, vibe.data.json and asdf", the below code works perfectely while use "std_data_json or vibe.data.json" but not working as expected when we use "asdf" and throwing the below error, hence request your help on the same.

Error:

source/app.d(12,2): Error: invalid foreach aggregate jv.opIndex(["items"][]), define opApply(), range primitives, or use .tupleof

Code:

import std.stdio: writeln;
import vibe.data.json;           // works
//import asdf;                   // Does not work.
import std.conv: to;

void main()
{
string apidata = `{"items":[{"name":"T10","hostname":"test1","type":[{"typeValue":"TD,d...@dev.com,DEVt"},{"typeno":"000"}]},{"name":"T11","hostname":"test2","type":[{"typeValue":"TF,q...@qas.com,QAS"},{"typeno":"100"}]},{"name":"T11","hostname":"test3","type":[{"typeValue":"TP,p...@prd.com,PRD"},{"typeno":"101"}]}]}`;
 auto jv = parseJson(apidata);
 foreach(j; jv["items"]){
    writeln(j["name"].toString());
 }
}

Vino.B

Reply via email to