Help on asdf json module

Vino akashvino79 at gmail.com
Sun Oct 25 06:05:27 UTC 2020


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,dev at dev.com,DEVt"},{"typeno":"000"}]},{"name":"T11","hostname":"test2","type":[{"typeValue":"TF,qas at qas.com,QAS"},{"typeno":"100"}]},{"name":"T11","hostname":"test3","type":[{"typeValue":"TP,prd at prd.com,PRD"},{"typeno":"101"}]}]}`;
  auto jv = parseJson(apidata);
  foreach(j; jv["items"]){
     writeln(j["name"].toString());
  }
}

Vino.B


More information about the Digitalmars-d-learn mailing list